Hi,
I couldn't find a way to checkout locally a pull request in Stash.
Let's say that Dev1 created a pull request for Dev2. How is Dev2 supposed to try that code locally before approving/rejecting that pull request?
In a Github-like scenario, Dev2 would create a local branch related to that pull request...
It seems that it's not possible to do the same thing in Stash?
Thanks in advance,
Stefano
Community moderators have prevented the ability to post new answers.
Hi Charles,
I know I could add the other repo as a remote, but it has some drawbacks:
However, your "worst case" appears to be my ideal solution...
I've just created an alias:
[alias] prstash = "!f() { git fetch $1 refs/pull-requests/$2/from:$3; } ; f"
and now I can just type:
git prstash origin 3 dest-branch
to checkout the 3rd pull request onto dest-branch!
Thanks!
I got this working but I had a question, is there a way to update the branch when the person making the pull request makes an update to the request?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefano,
The workflow for checking out a local PR should be identical to using GitHub. If the pull request is between branches in a single repository, you can just checkout (create a local branch) of their source. If you're using a forking workflow, you will need to add their personal repository as a Git 'remote' and then checkout.
Or is the problem that you don't have access to their repository? On our team we normally add permissions to their forked repository to our teams group so we can fetch from them in these scenarios.
In the worst case, where someone may not be around to update their permissions (or chooses not to) you can run the following to get access to the 'from' branch of any pull request:
git fetch origin refs/pull-requests/$PR_NO/from:$LOCAL_BRANCH
Where $PR_NO is the number of your pull request.
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this something that can be added into the helper text in Stash Pull Request view, to enable teams an easier job to pull down pull requests locally and run whatever tests and other things before approving the merge? This would REALLY be helpful for a large organization setting, where teams don't constantly flip permissions back and forth for all the pull requests from forks.
This is an example of how it is done in Gitorious:
One way to merge in these changes is to pull them into a local branch for review, verifying the changes and then merge to back to master. # Check out a new branch for integration git checkout -b merge-requests/8 # Fetch the merge request into this branch git pull \ git://git.orbitz.net/continuous-delivery/jenkins-jobdsl.git \ refs/merge-requests/8 # Show the commits, assess they are okay git log --pretty=oneline --abbrev-commit next..merge-requests/8
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex,
I'm afraid we don't really want to publicly advertise the (internal) pull-requests ref. It's an internal implementation detail that just happens to be usable from Git if you know how.
There are a few options, depending on the use-cases we need to support. I've created a feature request which you might want to follow and vote on. If you would be so kind as to document your workflow on the issue with a commen as well that would be most kind.
https://jira.atlassian.com/browse/STASH-3625
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Charles,
I've added the description of the possible flow to the Jira you've provided.
I've also opened another Jira - https://jira.atlassian.com/browse/STASH-3623, so you might want to link them together.
Thanks,
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Alex. I've closed your issue as a duplicate to make it easier to track.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys, I'm in a similar situation, where I am reviewing a PR from a fork that I don't have permissions to view/clone. I've tried using your internal API as a temporary workaround, but that no longer seems to work. I also looked at the Jira referenced here, but that doesn't seem to have made any progress. Any suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Graham,
How do you mean no longer works? If you run 'git ls-remote' what do you see? At a previous version of Stash (I can't remember which) Stash no longer kept the refs for merged/rejected PRs, but other than that it should still as normal/expected.
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Huh, I guess I can see it in the remotes, but when I tried to fetch it, I get
fatal: 'refs/pull-requests/6/from' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Graham,
Looks like you're using the wrong command. It should be something like:
git fetch origin refs/pull-requests/6/from:local_name
I suspect you're leaving off the the 'origin' part.
EDIT: Whoops, looks like I started it with the incorrect command in my answer. I'll fix that now.
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah yes, that was exactly it. Thanks a lot :) Added a vote to the Jira issue as well, hopefully something to enable this will be added at some point.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I created a bookmarklet that does this
javascript:(function()%7Bbranch %3D jQuery('.ref.branch .name%3Afirst').text()%3Bref %3D 'refs%2Fheads%2F' %2B branch%3Bref %3D encodeURIComponent(ref)%3Busername %3D jQuery('%23current-user').attr('data-username')%3BsourceTreeLink %3D jQuery('%23sourcetree-clone-button').attr('href')%3Blocation.href %3D sourceTreeLink.replace('cloneRepo%3F'%2C'checkoutRef%3Fref%3D' %2B ref %2B '%26')%7D)()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.