1

I am trying Stash, and I observe something that I cannot understand:

  • I push a new branch;
  • I create a pull request (from the browser);
  • Then I am trying to do:

    $ git fetch origin +refs/pull-requests/*:refs/remotes/origin/pr/* --dry-run
    

Sometimes, it is working immediately, but sometimes, the pull request only shows up after a long delay (30 minutes or so).

Stash is installed locally, so the delay doesn't come from the network, and the other interactions are ok.

Anne
  • 1,270
  • 6
  • 15

1 Answers1

1

Pull request refs are calculated lazily based on people viewing the diff in the UI or certain other operations. This is done for performance reasons, and the refs you're fetching aren't officially part of Stash API. This is something we're considering changing, buy we need to be mindful of the performance impact.

May I ask what it is that you're trying to do with the theoretical merge ref? Perhaps there's an alternative approach.

(I'm a product manager for Stash)

Rog
  • 4,075
  • 2
  • 24
  • 35
  • Thank you for the explanation. It was driving me crazy. I first observe this strange behavior in Jenkins that was able to see that there were a new pull request, but not able to fetch the correct branch... so, to make it work, we need to "play" with the UI when after the PR creation ? – Anne Jul 18 '15 at 05:53
  • Ideally one just fetches and build the source branch. Whilst it is possible to build the effective merge as you suggest, if the target branch moves at all the results become less relevant, unless you constantly rebuild for either branch tip moving. – Rog Jul 20 '15 at 02:26
  • I wanted to fetch and build the /from part of the pull request (not the /merge one) ie the source branch. But I cannot do it on the branch itself since it usually comes from another repository on which I don't necessary have the permitions. – Anne Jul 20 '15 at 05:57
  • Ah, I see. The answer still applies in that case, and it's something we'd like to improve at least as much. – Rog Jul 21 '15 at 07:04
  • One suggestion in the meantime from a developer: you could write a plugin that listens for PullRequestRescopedEvent, detects when the from ref moves, and calls PullRequestService.canMerge That will ensure the from ref is always up to date – Rog Jul 21 '15 at 07:05
  • Thanks for your suggestion. I am using the Jenkins "Stash pullrequest builder plugin" at the moment. I would expect it to do such think. I'll have a look. – Anne Jul 21 '15 at 07:28
  • The developer of this plug-in told me in here https://github.com/nemccarthy/stash-pullrequest-builder-plugin/issues/32 that this is implemented when the two advanced options "Build only if Stash reports no conflicts" and "Build only if PR is mergeable" are set. So everything if fine then. – Anne Jul 21 '15 at 08:23