Skip to content

Commit

Permalink
add refs/stash and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhaochen committed Jun 15, 2022
1 parent 4d1004b commit 42b4bc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions commands/command_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

0 comments on commit 42b4bc2

Please sign in to comment.