From 552e8abe527b9f18dd9a11fb223425b8e043003f Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Fri, 11 Sep 2015 17:36:31 +0100 Subject: [PATCH] Implement retention of current checkout --- commands/command_prune.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/commands/command_prune.go b/commands/command_prune.go index 22bb3250..8fdfce24 100644 --- a/commands/command_prune.go +++ b/commands/command_prune.go @@ -6,6 +6,7 @@ import ( "os" "sync" + "github.com/github/git-lfs/git" "github.com/github/git-lfs/lfs" "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) @@ -280,7 +281,21 @@ func pruneTaskGetLocalObjects(outLocalObjects *[]*lfs.Pointer, progChan PrunePro func pruneTaskGetRetainedCurrentCheckout(retainChan chan string, errorChan chan error, waitg *sync.WaitGroup) { defer waitg.Done() - // TODO + ref, err := git.CurrentRef() + if err != nil { + errorChan <- err + return + } + // Only files AT ref, recent is checked in pruneTaskGetRetainedRecentRefs + opts := &lfs.ScanRefsOptions{ScanMode: lfs.ScanRefsMode, SkipDeletedBlobs: true} + refchan, err := lfs.ScanRefsToChan(ref.Sha, "", opts) + if err != nil { + errorChan <- err + return + } + for wp := range refchan { + retainChan <- wp.Pointer.Oid + } } // Background task, must call waitg.Done() once at end