{"action":"created","issue":{"url":"https://api.github.com/repos/capistrano/capistrano/issues/1543","repository_url":"https://api.github.com/repos/capistrano/capistrano","labels_url":"https://api.github.com/repos/capistrano/capistrano/issues/1543/labels{/name}","comments_url":"https://api.github.com/repos/capistrano/capistrano/issues/1543/comments","events_url":"https://api.github.com/repos/capistrano/capistrano/issues/1543/events","html_url":"https://github.com/capistrano/capistrano/issues/1543","id":124005227,"node_id":"MDU6SXNzdWUxMjQwMDUyMjc=","number":1543,"title":"Using before/after with a fully-qualified (namespaced) task has unexpected behavior ","user":{"login":"mattbrictson","id":189693,"node_id":"MDQ6VXNlcjE4OTY5Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/189693?v=4","gravatar_id":"","url":"https://api.github.com/users/mattbrictson","html_url":"https://github.com/mattbrictson","followers_url":"https://api.github.com/users/mattbrictson/followers","following_url":"https://api.github.com/users/mattbrictson/following{/other_user}","gists_url":"https://api.github.com/users/mattbrictson/gists{/gist_id}","starred_url":"https://api.github.com/users/mattbrictson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattbrictson/subscriptions","organizations_url":"https://api.github.com/users/mattbrictson/orgs","repos_url":"https://api.github.com/users/mattbrictson/repos","events_url":"https://api.github.com/users/mattbrictson/events{/privacy}","received_events_url":"https://api.github.com/users/mattbrictson/received_events","type":"User","site_admin":false},"labels":[{"id":55267081,"node_id":"MDU6TGFiZWw1NTI2NzA4MQ==","url":"https://api.github.com/repos/capistrano/capistrano/labels/confirmed%20bug","name":"confirmed bug","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2015-12-28T01:34:58Z","updated_at":"2018-11-01T17:35:18Z","closed_at":null,"author_association":"MEMBER","body":"Capistrano's `before` and `after` work with `namespace` blocks, thanks to 5fcf3da. Given this:\n\n``` ruby\nnamespace :deploy do\n  after :updated, :foo do\n    # ...\n  end\nend\n```\n\nHere everything works as expected:\n1. a `deploy:foo` task is created\n2. the existing `deploy:updated` task is enhanced\n3. at runtime, `deploy:foo` is invoked after `deploy:updated`\n\nHowever, doing the same thing by fully-qualifying the task name instead of using the `namespace` block leads to some very odd behavior. Consider:\n\n``` ruby\nafter \"deploy:updated\", :foo do\n  # ...\nend\n```\n\nIn this case:\n1. a `foo` task is created at the root level (as expected)\n2.  the existing `deploy:updated` task is enhanced\n3. at runtime, **`deploy:foo`** (huh?) is invoked after `deploy:updated`\n\nWhen `deploy:updated` is invoked, Capistrano tries to find and invoke `deploy:foo`. The only reason the deploy still works is because Rake is smart enough to also search for the root `foo` when it fails to find `deploy:foo`.\n\nThis is confusing, and I think dangerous.\n\nConsider this example (see #1542):\n\n``` ruby\nafter \"deploy:failed\", :failed do\n  # ...\nend\n```\n\nThis task enhancement doesn't work! Even though a new root level `failed` task has been defined, Capistrano looks up `deploy:failed` at runtime instead. So essentially what has been accomplished is `deploy:failed` has been enhanced with itself! The root `failed` task is never invoked.\n\nI think the desired (and intuitive) behavior is that the task being defined in the `after` block should be the same task that is invoked. \n"},"comment":{"url":"https://api.github.com/repos/capistrano/capistrano/issues/comments/435121314","html_url":"https://github.com/capistrano/capistrano/issues/1543#issuecomment-435121314","issue_url":"https://api.github.com/repos/capistrano/capistrano/issues/1543","id":435121314,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTEyMTMxNA==","user":{"login":"jarthod","id":201687,"node_id":"MDQ6VXNlcjIwMTY4Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/201687?v=4","gravatar_id":"","url":"https://api.github.com/users/jarthod","html_url":"https://github.com/jarthod","followers_url":"https://api.github.com/users/jarthod/followers","following_url":"https://api.github.com/users/jarthod/following{/other_user}","gists_url":"https://api.github.com/users/jarthod/gists{/gist_id}","starred_url":"https://api.github.com/users/jarthod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarthod/subscriptions","organizations_url":"https://api.github.com/users/jarthod/orgs","repos_url":"https://api.github.com/users/jarthod/repos","events_url":"https://api.github.com/users/jarthod/events{/privacy}","received_events_url":"https://api.github.com/users/jarthod/received_events","type":"User","site_admin":false},"created_at":"2018-11-01T17:35:18Z","updated_at":"2018-11-01T17:35:18Z","author_association":"NONE","body":"Ok I see, yeah I can imagine the difficulty to change that.\r\nI guess you know better than me but just in case I think you may be able to introduce this kind of change with a feature flag (like rails does) so people can start using this new strategy (which would be present in newly generated deploy.rb files but not in older so no breaking). Or with a deprecation warning saying \"be careful in 4.x this after hook will not run the task you want again unless you change the value to 'xxx.xxx'\"."}}
{"actor":{"display_login":"jarthod"}}