{"action":"created","issue":{"url":"https://api.github.com/repos/jtarchie/pullrequest-resource/issues/33","repository_url":"https://api.github.com/repos/jtarchie/pullrequest-resource","labels_url":"https://api.github.com/repos/jtarchie/pullrequest-resource/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/jtarchie/pullrequest-resource/issues/33/comments","events_url":"https://api.github.com/repos/jtarchie/pullrequest-resource/issues/33/events","html_url":"https://github.com/jtarchie/pullrequest-resource/issues/33","id":175036482,"number":33,"title":"Fails to fetch changes when pull request is made from a 'master' branch","user":{"login":"nathgs","id":632913,"avatar_url":"https://avatars.githubusercontent.com/u/632913?v=3","gravatar_id":"","url":"https://api.github.com/users/nathgs","html_url":"https://github.com/nathgs","followers_url":"https://api.github.com/users/nathgs/followers","following_url":"https://api.github.com/users/nathgs/following{/other_user}","gists_url":"https://api.github.com/users/nathgs/gists{/gist_id}","starred_url":"https://api.github.com/users/nathgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathgs/subscriptions","organizations_url":"https://api.github.com/users/nathgs/orgs","repos_url":"https://api.github.com/users/nathgs/repos","events_url":"https://api.github.com/users/nathgs/events{/privacy}","received_events_url":"https://api.github.com/users/nathgs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-05T09:56:34Z","updated_at":"2016-09-12T05:19:31Z","closed_at":null,"body":"The pullrequest-resource `in` outputs the following error, but doesn't fail completely:\r\n```\r\nfatal: Refusing to fetch into current branch refs/heads/master of non-bare repository\r\nAlready on 'master'\r\nYour branch is up-to-date with 'origin/master'.\r\n```\r\nThis results in strange behaviour where the pullrequest-resource has cloned the git repository, but not fetched the changes from the pull request. The subsequent steps in the build plan continue to execute without including the pull request changes.\r\n\r\nSteps to reproduce:\r\n1) Create a pipeline with using pullrequest-resource pointing to a repository let's call it `usera/repo`\r\n2) Fork the repo into another user account `userb/repo`\r\n3) Make some trivial change to the `master` of `userb/repo` (it's important the change is made in `master`) and create a pull request from `userb/repo:master` to `usera/repo:master`\r\n4) Check the pipeline `in` for the pullrequest-resource\r\n\r\nExpected outcome:\r\nThe `in` of pullrequest-resource should fetch the changes from the pull request we should see the changes from `userb/repo:master` in Concourse.\r\n\r\nActual outcome:\r\nThe `in` of pullrequest-resource fails to fetch the changes from the pull request. It also doesn't fail in an obvious way it outputs the error but then exits with success. We see only the contents of `usera/repo:master` in Concourse.\r\n\r\nThis only happens when the pull request is made from the `master` branch of the fork. The asset/lib/in.rb seems to assume the pull request is made from a branch other than `master` `branch_ref = pr['head']['ref']` what happens in this case is `branch_ref = 'master'` and then `system(\"git fetch -q origin pull/#{id}/head:#{branch_ref} 1>&2\")` results in the `Already on 'master'` error. Quick workaround hack is to hardcode `branch_ref = 'tmp'`, but that has other implications so not a full solution.\r\n"},"comment":{"url":"https://api.github.com/repos/jtarchie/pullrequest-resource/issues/comments/246252204","html_url":"https://github.com/jtarchie/pullrequest-resource/issues/33#issuecomment-246252204","issue_url":"https://api.github.com/repos/jtarchie/pullrequest-resource/issues/33","id":246252204,"user":{"login":"jtarchie","id":75184,"avatar_url":"https://avatars.githubusercontent.com/u/75184?v=3","gravatar_id":"","url":"https://api.github.com/users/jtarchie","html_url":"https://github.com/jtarchie","followers_url":"https://api.github.com/users/jtarchie/followers","following_url":"https://api.github.com/users/jtarchie/following{/other_user}","gists_url":"https://api.github.com/users/jtarchie/gists{/gist_id}","starred_url":"https://api.github.com/users/jtarchie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtarchie/subscriptions","organizations_url":"https://api.github.com/users/jtarchie/orgs","repos_url":"https://api.github.com/users/jtarchie/repos","events_url":"https://api.github.com/users/jtarchie/events{/privacy}","received_events_url":"https://api.github.com/users/jtarchie/received_events","type":"User","site_admin":false},"created_at":"2016-09-12T05:19:31Z","updated_at":"2016-09-12T05:19:31Z","body":"The reproducing steps from the `in` step for the previous step would be.\r\n\r\n```\r\ngit clone --depth 1 git@github.com:jtarchie/pullrequest-resource.git testing\r\ngit submodule update --init --recursive\r\ngit fetch -q origin pull/34/head:pr-34\r\n```\r\n\r\nAny insight in the git repo you have would be great or minimal steps to reproduce.\r\n\r\nSorry the above is stream of thought."}}
{"actor":{"display_login":"jtarchie"}}