From 42b4bc25a3ae66ce7c3fffa86bfb27662368ccd2 Mon Sep 17 00:00:00 2001 From: Haochen Wu Date: Tue, 14 Jun 2022 20:36:19 -0700 Subject: [PATCH] add refs/stash and tests --- commands/command_migrate.go | 7 +++++++ commands/commands_test.go | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/commands/command_migrate.go b/commands/command_migrate.go index 32584be4..baa893fa 100644 --- a/commands/command_migrate.go +++ b/commands/command_migrate.go @@ -128,6 +128,13 @@ func rewriteOptions(args []string, opts *githistory.RewriteOptions, l *tasklog.L // isSpecialGitRef checks if a ref spec is a special git ref to exclude from // --everything func isSpecialGitRef(refspec string) bool { + // Special refspecs. + switch refspec { + case "refs/stash": + return true + } + + // Special refspecs from namespaces. parts := strings.SplitN(refspec, "/", 3) if len(parts) < 3 { return false diff --git a/commands/commands_test.go b/commands/commands_test.go index 01d20f49..c23a0d69 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -47,3 +47,11 @@ func TestDetermineIncludeExcludePathsReturnsNothingWhenAbsent(t *testing.T) { assert.Empty(t, i) assert.Empty(t, e) } + +func TestSpecialGitRefsExclusion(t *testing.T) { + assert.True(t, isSpecialGitRef("refs/notes/commits")) + assert.True(t, isSpecialGitRef("refs/bisect/bad")) + assert.True(t, isSpecialGitRef("refs/replace/abcdef90")) + assert.True(t, isSpecialGitRef("refs/stash")) + assert.False(t, isSpecialGitRef("refs/commits/abcdef90")) +}