Skip to content

Commit fb6314a

Browse files
committed
update merge method to take in signature
1 parent bf2acf9 commit fb6314a

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

lib/repository.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ function(name, commit, force, signature, logMessage) {
6060
* @return {Ref}
6161
*/
6262
Repository.prototype.getBranch = function(name, callback) {
63-
name = name instanceof Reference || ~name.indexOf("refs/heads/")
64-
? name
65-
: "refs/heads/" + name;
63+
name = (name instanceof Reference ||
64+
~name.indexOf("refs/heads/")) ? name
65+
: "refs/heads/" + name;
6666

6767
return this.getReference(name).then(function(reference) {
6868
if (typeof callback === "function") {
@@ -531,11 +531,13 @@ Repository.prototype.fetchAll = function() {
531531
* @return {Oid|Index} A commit id for a succesful merge or an index for a
532532
* merge with conflicts
533533
*/
534-
Repository.prototype.mergeBranches = function(to, from) {
534+
Repository.prototype.mergeBranches = function(to, from, signature) {
535535
var repo = this;
536536
var fromBranch;
537537
var toBranch;
538538

539+
signature = signature || repo.defaultSignature();
540+
539541
return Promise.all([
540542
repo.getBranch(to),
541543
repo.getBranch(from)
@@ -568,7 +570,7 @@ Repository.prototype.mergeBranches = function(to, from) {
568570

569571
return toBranch.setTarget(
570572
fromCommitOid,
571-
repo.defaultSignature(),
573+
signature,
572574
message)
573575
.then(function() {
574576
return fromCommitOid;
@@ -593,12 +595,11 @@ Repository.prototype.mergeBranches = function(to, from) {
593595
" into " +
594596
toBranch.shorthand();
595597
console.log(message);
596-
var sig = repo.defaultSignature();
597598

598599
return repo.createCommit(
599600
toBranch.name(),
600-
sig,
601-
sig,
601+
signature,
602+
signature,
602603
message,
603604
oid,
604605
[toCommitOid, fromCommitOid]);

test/tests/merge.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,14 @@ describe("Merge", function() {
219219
assert.equal(oid.toString(),
220220
"0e9231d489b3f4303635fc4b0397830da095e7e7");
221221

222-
return repository.getBranchCommit(ourBranchName).then(function(branchCommit) {
223-
assert.equal(oid.toString(), branchCommit.toString());
224-
});
222+
return repository.getBranchCommit(ourBranchName)
223+
.then(function(branchCommit) {
224+
assert.equal(oid.toString(), branchCommit.toString());
225+
});
225226
});
226227
});
227228

228-
it.only("can merge cleanly using the convenience method", function() {
229+
it("can merge cleanly using the convenience method", function() {
229230
var initialFileName = "initialFile.txt";
230231
var ourFileName = "ourNewFile.txt";
231232
var theirFileName = "theirNewFile.txt";
@@ -343,11 +344,12 @@ describe("Merge", function() {
343344
});
344345
})
345346
.then(function() {
346-
return repository.mergeBranches(ourBranchName, theirBranchName);
347+
return repository.mergeBranches(ourBranchName, theirBranchName,
348+
ourSignature);
347349
})
348350
.then(function(commitId) {
349351
assert.equal(commitId.toString(),
350-
"0e9231d489b3f4303635fc4b0397830da095e7e7");
352+
"5384feb481d9c29081b3a0c1478fcc24a3953efa");
351353
});
352354
});
353355

0 commit comments

Comments
 (0)