Handle allow-unrelated-histories option on pull

This commit is contained in:
Nick O'Leary
2018-02-08 23:21:14 +00:00
parent d5619d2b9d
commit 06a6a4408f
5 changed files with 88 additions and 54 deletions

View File

@@ -512,7 +512,7 @@ Project.prototype.push = function (user,remoteBranchName,setRemote) {
return gitTools.push(this.path, remote.remote || this.currentRemote,remote.branch, setRemote, authCache.get(this.name,this.remotes[remote.remote || this.currentRemote].fetch,username));
};
Project.prototype.pull = function (user,remoteBranchName,setRemote) {
Project.prototype.pull = function (user,remoteBranchName,setRemote,allowUnrelatedHistories) {
var username;
if (!user) {
username = "_";
@@ -523,11 +523,11 @@ Project.prototype.pull = function (user,remoteBranchName,setRemote) {
if (setRemote) {
return gitTools.setUpstream(this.path, remoteBranchName).then(function() {
self.currentRemote = self.parseRemoteBranch(remoteBranchName).remote;
return gitTools.pull(self.path, null, null, authCache.get(self.name,self.remotes[self.currentRemote].fetch,username),getGitUser(user));
return gitTools.pull(self.path, null, null, allowUnrelatedHistories, authCache.get(self.name,self.remotes[self.currentRemote].fetch,username),getGitUser(user));
})
} else {
var remote = this.parseRemoteBranch(remoteBranchName);
return gitTools.pull(this.path, remote.remote, remote.branch, authCache.get(this.name,this.remotes[remote.remote||self.currentRemote].fetch,username),getGitUser(user));
return gitTools.pull(this.path, remote.remote, remote.branch, allowUnrelatedHistories, authCache.get(this.name,this.remotes[remote.remote||self.currentRemote].fetch,username),getGitUser(user));
}
};

View File

@@ -428,7 +428,7 @@ module.exports = {
var args = ["branch","--set-upstream-to",remoteBranch];
return runGitCommand(args,cwd);
},
pull: function(cwd,remote,branch,auth,gitUser) {
pull: function(cwd,remote,branch,allowUnrelatedHistories,auth,gitUser) {
var args = ["pull"];
if (remote && branch) {
args.push(remote);
@@ -440,8 +440,9 @@ module.exports = {
args.unshift('user.email="'+gitUser['email']+'"');
args.unshift('-c');
}
//TODO: only do this if asked for
args.push("--allow-unrelated-histories");
if (allowUnrelatedHistories) {
args.push("--allow-unrelated-histories");
}
var promise;
if (auth) {
if ( auth.key_path ) {

View File

@@ -241,9 +241,9 @@ function push(user, project,remoteBranchName,setRemote) {
checkActiveProject(project);
return activeProject.push(user,remoteBranchName,setRemote);
}
function pull(user, project,remoteBranchName,setRemote) {
function pull(user, project,remoteBranchName,setRemote,allowUnrelatedHistories) {
checkActiveProject(project);
return activeProject.pull(user,remoteBranchName,setRemote).then(function() {
return activeProject.pull(user,remoteBranchName,setRemote,allowUnrelatedHistories).then(function() {
return reloadActiveProject("pull");
});
}