3

I am trying to create a pull request from specific commit. Is it possible?

Detail:

There is commit c1, c2, c3 in branch b1, and commit c3 is also in branch b2. Create a pull request to merge commit c2 into branch b2.

My failed attempts:

  • Create a new branch from specific commit, couldn't find any VS team services API for this.
  • Create a tag on specific commit, don't know how to, only found get tag api.
  • Build a temporary branch b3 from b2, cherry-pick commit c2 to b3 and create pull request from b3 to b2. I don't see any way to pick a existing commit to a branch from official document.
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
mosyu
  • 57
  • 1
  • 8
  • There is no specific command for Cherry Pick on the server. A cherry pick is just a commit. You'll need to craft the commit you want and push that to the rest API. – jessehouwing Oct 08 '16 at 08:44
  • @jessehouwing I have updated the question. Could you help take a look? I am also trying your suggestion. – mosyu Oct 08 '16 at 08:49
  • 2
    Simplest way to do this would be to clone your repo locally, execute the commands and push them back into the service. Right now the REST API only works for simple type commits and all the hard work needs to be done by you. It's much easier to let the normal commandline tools handle that. – jessehouwing Oct 08 '16 at 08:56
  • The way to do it would be to: clone the target branch, create a new branch off of that, cherry pick the commitid, commit, push the new branch, create a pull request. – jessehouwing Oct 08 '16 at 08:57
  • Thanks for your reply @jessehouwing. Yes, local repo can achieve this. But I want to add this to continuous integration system, in this way, I have to clone code in server side and keep this code up to date. – mosyu Oct 08 '16 at 09:02
  • Yes you'd have to. But short of crafting the commit yourself and performing all the merges yourself, there is no way to do it. The Server API is kind of stupid and doesn't perform merges, conflict resolution etc. It just overwrites the content or applies the patch you submit. Since you're doing CI, isn't the repo already available? Or are you updating another repo? Can't you add the other repo as a remote to the one you have locally and resolve all issues locally, then push? – jessehouwing Oct 08 '16 at 09:06
  • This CI don't have local repo:) It just call other existing service to finish it's global. According to your suggestion. I agree this is the simplest way. Thanks! – mosyu Oct 08 '16 at 09:16
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/125224/discussion-between-mosyu-and-jessehouwing). – mosyu Oct 08 '16 at 09:17

1 Answers1

2

Since the REST Api doesn't have any features to perform merges nor conflict resolution, anything that has to do with merges, rebases, cherry-picks etc needs to be performed locally before pushing the commit data back to VSTS.

The simplest solution would be to perform a clone of the target repo and then to perform the changes before pushing them back.

Depending on what you're trying to accomplish, a shallow clone may suffice, though if you want to cherry pick old commits, that may not work for you.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341