Skip to content

Commit

Permalink
Fix: Git reconciliation preference (#98)
Browse files Browse the repository at this point in the history
Specifies a git preference for merging when there is difference between branches/projects
  • Loading branch information
AnonymousWalker authored Dec 7, 2022
1 parent 8f71a13 commit 20ba929
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/js/gitnative.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ var path = require('path'),
utils = require('../js/lib/utils'),
cmdr = require('../js/lib/cmdr');

const ALLOW_UNRELATED_HISTORIES = '--allow-unrelated-histories';
const NO_REBASE = '--rebase=false';

// NOTE: could use moment module for this
function createTagName(datetime) {
return 'R2P/' +
Expand Down Expand Up @@ -138,15 +141,14 @@ function GitManager() {
return mythis.getVersion();
})
.then(function (version) {
var diff = cmd().cd(localPath).and.do('git diff --name-only --diff-filter=U');
var pull = "";

const diff = cmd().cd(localPath).and.do('git diff --name-only --diff-filter=U');
let pullCommand = `git pull "${remotePath}" master ${NO_REBASE}`;
if (version.major > 2 || (version.major == 2 && version.minor > 8)) {
pull = cmd().cd(localPath).and.do(`git pull "${remotePath}" master --allow-unrelated-histories`);
} else {
pull = cmd().cd(localPath).and.do(`git pull "${remotePath}" master`);
pullCommand += ` ${ALLOW_UNRELATED_HISTORIES}`;
}


const pull = cmd().cd(localPath).and.do(pullCommand);
return pull.run()
.catch(function (err) {
if (err.stdout.includes('fix conflicts')) {
Expand Down Expand Up @@ -182,7 +184,11 @@ function GitManager() {
return mythis.commitAll(user, localPath);
})
.catch(function (err) {
throw "Error while merging projects: " + err.stderr;
if (err.stderr != undefined) {
throw "Error while merging projects: " + err.stderr;
} else {
console.error(err);
}
})
.then(utils.logr("Finished merging"))
.then(function () {
Expand Down

0 comments on commit 20ba929

Please sign in to comment.