@@ -53,37 +53,17 @@ function(name, commit, force, signature, logMessage) {
5353} ;
5454
5555/**
56- * Look up a branch
56+ * Look up a refs's commit.
5757 *
58- * @param {String|Ref } name Branch name, e.g. "master" or Branch Ref
59- * @param {Function } callback
60- * @return {Ref }
61- */
62- Repository . prototype . getBranch = function ( name , callback ) {
63- name = ( name instanceof Reference ||
64- ~ name . indexOf ( "refs/heads/" ) ) ? name
65- : "refs/heads/" + name ;
66-
67- return this . getReference ( name ) . then ( function ( reference ) {
68- if ( typeof callback === "function" ) {
69- callback ( null , reference ) ;
70- }
71-
72- return reference ;
73- } , callback ) ;
74- } ;
75-
76- /**
77- * Look up a branch's most recent commit.
78- *
79- * @param {String|Ref } name Branch name, e.g. "master" or Branch Ref
58+ * @param {String|Ref } name Ref name, e.g. "master", "refs/heads/master"
59+ * or Branch Ref
8060 * @param {Function } callback
8161 * @return {Commit }
8262 */
83- Repository . prototype . getBranchCommit = function ( name , callback ) {
63+ Repository . prototype . getReferenceCommit = function ( name , callback ) {
8464 var repository = this ;
8565
86- return this . getBranch ( name ) . then ( function ( reference ) {
66+ return this . getReference ( name ) . then ( function ( reference ) {
8767 return repository . getCommit ( reference . target ( ) ) . then ( function ( commit ) {
8868 if ( typeof callback === "function" ) {
8969 callback ( null , commit ) ;
@@ -94,6 +74,30 @@ Repository.prototype.getBranchCommit = function(name, callback) {
9474 } , callback ) ;
9575} ;
9676
77+ /**
78+ * Look up a branch. Alias for `getReference`
79+ *
80+ * @param {String|Ref } name Ref name, e.g. "master", "refs/heads/master"
81+ * or Branch Ref
82+ * @param {Function } callback
83+ * @return {Ref }
84+ */
85+ Repository . prototype . getBranch = function ( name , callback ) {
86+ return this . getReference ( name , callback ) ;
87+ } ;
88+
89+ /**
90+ * Look up a branch's most recent commit. Alias to `getReferenceCommit`
91+ *
92+ * @param {String|Ref } name Ref name, e.g. "master", "refs/heads/master"
93+ * or Branch Ref
94+ * @param {Function } callback
95+ * @return {Commit }
96+ */
97+ Repository . prototype . getBranchCommit = function ( name , callback ) {
98+ return this . getReferenceCommit ( name , callback ) ;
99+ } ;
100+
97101/**
98102 * Gets the branch that HEAD currently points to
99103 * Is an alias to head()
@@ -106,14 +110,15 @@ Repository.prototype.getCurrentBranch = function() {
106110/**
107111 * Lookup the reference with the given name.
108112 *
109- * @param {String } name
113+ * @param {String|Ref } name Ref name, e.g. "master", "refs/heads/master"
114+ * or Branch Ref
110115 * @param {Function } callback
111116 * @return {Reference }
112117 */
113118Repository . prototype . getReference = function ( name , callback ) {
114119 var repository = this ;
115120
116- return Reference . lookup ( this , name ) . then ( function ( reference ) {
121+ return Reference . dwim ( this , name ) . then ( function ( reference ) {
117122 if ( reference . isSymbolic ( ) ) {
118123 return reference . resolve ( ) . then ( function ( reference ) {
119124 reference . repo = repository ;
@@ -507,29 +512,47 @@ Repository.prototype.getRemote = function(remote, callback) {
507512 *
508513 * @param {String|Remote } remote
509514 */
510- Repository . prototype . fetch = function ( remote ) {
515+ Repository . prototype . fetch = function (
516+ remote ,
517+ remoteCallbacks ,
518+ ignoreCertErrors ,
519+ callback )
520+ {
511521 var repo = this ;
512522
513523 return repo . getRemote ( remote ) . then ( function ( remote ) {
514- return remote . fetch ( repo . defaultSignature ( ) ) ;
515- } ) ;
524+ remote . setCallbacks ( remoteCallbacks ) ;
525+ remote . checkCert ( ignoreCertErrors ? 0 : 1 ) ;
526+
527+ return remote . fetch ( repo . defaultSignature ( ) , "Fetch from " + remote )
528+ . then ( function ( ) {
529+ if ( typeof callback === "function" ) {
530+ callback ( ) ;
531+ }
532+ } ) ;
533+ } , callback ) ;
516534} ;
517535
518536/**
519537 * Fetches from all remotes
520538 */
521- Repository . prototype . fetchAll = function ( ) {
539+ Repository . prototype . fetchAll = function (
540+ remoteCallbacks ,
541+ ignoreCertErrors ,
542+ callback )
543+ {
522544 var repo = this ;
523545
524- return repo . getRemotes ( function ( remotes ) {
546+ return repo . getRemotes ( ) . then ( function ( remotes ) {
525547 var fetchPromises = [ ] ;
526548
527549 remotes . forEach ( function ( remote ) {
528- fetchPromises . push ( repo . fetch ( remote ) ) ;
550+ fetchPromises . push (
551+ repo . fetch ( remote , remoteCallbacks , ignoreCertErrors , callback ) ) ;
529552 } ) ;
530553
531554 return Promise . all ( fetchPromises ) ;
532- } ) ;
555+ } , callback ) ;
533556} ;
534557
535558/**
0 commit comments