So I'm trying to do the following programmatically using the nodegit library:
Checkout hotfix branch Get head commmit from hotfix branch Create a topic branch whose head is pointed to hotfix branch head Set upstream topic branch to remote Cherry pick a commit from master and apply to topic branch Pause Developer fixes cherry pick merge and commits local changes Code then pushes Automatically create a pull request So it looks* like we get all the way to #4. When I perform these steps remotely using the VSO Rest SDK for node and there are no conflicts everything works on VSO just fine. It's just locally using nodegit.
Looks like as in all the objects returned from nodegit are native objects so cannot see any of the data using debug evaluate. Just get the prototype. So here's the nodegit code. Everytime I try to set the upstream branch I get errors about reference being invalid. Here's the code. See anything?
let hotfixBranch = conflict.parameters.ontoRefName.substr(conflict.parameters.ontoRefName.indexOf("hotfix"));
let topicBranch = conflict.parameters.generatedRefName.substr(conflict.parameters.generatedRefName.indexOf("hotfix"));
await this.checkoutRemoteBranch(this.repo, hotfixBranch)
.then(() => {
log.info(`Getting head commit for ${hotfixBranch}}`);
return this.repo.getHeadCommit()
})
.then(commit => {
log.info(`Creating local topic branch ${topicBranch} with head commit pointed to ${commit.id().tostrS()}`);
return this.repo.createBranch(topicBranch, commit, true);
})
.then((ref) => {
return git.Branch.setUpstream(ref, "origin")
})
.then(() => this.repo.checkoutBranch(topicBranch))
.then(() => {
log.info(`Performing cherry pick with id ${this.hotfixCommit.id().tostrS().cyan} ${"on branch".green} ${topicBranch.cyan}`);
return git.Cherrypick.cherrypick(this.repo, this.hotfixCommit, {});
})
.then(result => {
if (result === -1) {
log.section("Found cherry pick conflicts");
log.error("IMPORTANT");
log.instruction("---------");
log.instruction("You must now open the local enlistment and resolve the conflict. Perform the following steps");
log.instruction("1) Open the repo at: " + args.cloneRepoTo);
log.instruction("2) Fix any merge conflicts");
log.instruction("3) Stage the changes");
log.error("DO NOT PUSH THE CHANGES TO THE UPSTREAM BRANCH");
log.instruction("4) Come back to this window and PRESS ANY KEY TO CONTINUE");
return this.pressKeyToContinue();
}
return null;
})
.catch(err => {
log.error(`Error cherry picking to local branch ${err}`);
});
In the code above, the conflicts are VSO objects which I use to construct local nodegit objects.