Skip to content

Commit 76a0752

Browse files
author
John Haley
committed
Add option to fetch to prune the remote afterwards
Since pruning a remote is very common after a fetch I figured having it be an option would be very convenient for the user.
1 parent 8b3753f commit 76a0752

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/repository.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,12 @@ Repository.prototype.getRemote = function(remote, callback) {
596596
*
597597
* @param {String|Remote} remote
598598
* @param {Object|RemoteCallback} remoteCallbacks Any custom callbacks needed
599+
* @param {Bool} pruneAfter will perform a prune after the fetch if true
599600
*/
600601
Repository.prototype.fetch = function(
601602
remote,
602603
remoteCallbacks,
604+
pruneAfter,
603605
callback)
604606
{
605607
var repo = this;
@@ -608,6 +610,11 @@ Repository.prototype.fetch = function(
608610
remote.setCallbacks(remoteCallbacks);
609611

610612
return remote.fetch(null, repo.defaultSignature(), "Fetch from " + remote)
613+
.then(function() {
614+
if (pruneAfter) {
615+
remote.prune();
616+
}
617+
})
611618
.then(function() {
612619
return remote.disconnect();
613620
}).then(function() {
@@ -621,9 +628,11 @@ Repository.prototype.fetch = function(
621628
/**
622629
* Fetches from all remotes
623630
* @param {Object|RemoteCallback} remoteCallbacks Any custom callbacks needed
631+
* @param {Bool} pruneAfter will perform a prune after the fetch if true
624632
*/
625633
Repository.prototype.fetchAll = function(
626634
remoteCallbacks,
635+
pruneAfter,
627636
callback)
628637
{
629638
var repo = this;
@@ -633,7 +642,7 @@ Repository.prototype.fetchAll = function(
633642

634643
remotes.forEach(function(remote) {
635644
fetchPromises.push(
636-
repo.fetch(remote, remoteCallbacks, callback));
645+
repo.fetch(remote, remoteCallbacks, pruneAfter, callback));
637646
});
638647

639648
return Promise.all(fetchPromises);

0 commit comments

Comments
 (0)