Comparing version 0.1.0 to 0.2.0
42
merge.js
@@ -17,2 +17,6 @@ module.exports = function mergeRepo(states, msg) { | ||
obj.branches.push(state.key) | ||
// conflict on head: pick one | ||
if (state.head) obj.head = state.head | ||
for (var name in state.refUpdates) { | ||
@@ -55,6 +59,7 @@ var i = state.refUpdates[name] | ||
var author = ref.link && ref.link.value.author | ||
var conflictKey = key.replace(/^refs\/[^\/]*/, function ($0) { | ||
var refname = ref.realname || ref.name | ||
var conflictRefname = refname.replace(/^refs\/[^\/]*/, function ($0) { | ||
return $0 + '/' + author | ||
}) | ||
appendRef(conflictKey, { | ||
appendRef(conflictRefname, { | ||
realname: ref.name, | ||
@@ -70,8 +75,8 @@ conflict: true, | ||
if (msg) { | ||
var c = msg && msg.value.content | ||
if (c) { | ||
var commitTitles = {} | ||
var commits = msg.value.content.commits | ||
if (commits) { | ||
for (var i = 0; i < commits.length; i++) { | ||
var commit = commits[i] | ||
if (c.commits) { | ||
for (var i = 0; i < c.commits.length; i++) { | ||
var commit = c.commits[i] | ||
if (commit && commit.sha1 && commit.title) { | ||
@@ -83,9 +88,8 @@ commitTitles[commit.sha1] = commit.title | ||
var msgRefs = msg.value.content.refs | ||
if (msgRefs) { | ||
if (c.refs) { | ||
obj.refs = obj.refs.filter(function (ref) { | ||
return !(ref.name in msgRefs) | ||
return !(ref.name in c.refs) | ||
}) | ||
for (var name in msgRefs) { | ||
var hash = msgRefs[name] | ||
for (var name in c.refs) { | ||
var hash = c.refs[name] | ||
appendRef(name, { | ||
@@ -98,2 +102,5 @@ hash: hash, | ||
} | ||
if (c.head) obj.head = c.head | ||
obj.author = msg.value.author | ||
@@ -104,3 +111,14 @@ obj.sequence = msg.value.sequence | ||
if (!c || !c.head || !obj.head || obj.refUpdates[obj.head] < 0) { | ||
// pick an existing branch to use as HEAD, preferring the default branch | ||
// or something starting with it | ||
var refNames = obj.refs.map(function (ref) { return ref.name }) | ||
obj.head = ['refs/heads/master'].concat(refNames, | ||
refNames.filter(function (name) { | ||
return /^refs\/heads\/(.*\/)?master$/.test(name) | ||
}) | ||
).pop() | ||
} | ||
return obj | ||
} |
{ | ||
"name": "ssb-git", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "logic for working with git-ssb repos", | ||
@@ -5,0 +5,0 @@ "author": "Charles Lehner (http://celehner.com/)", |
@@ -30,2 +30,3 @@ # ssb-git | ||
ref is deleted. | ||
- `head`: ref name for symbolic ref `HEAD` (the repo's default branch) | ||
@@ -32,0 +33,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4497
106
44