commands/command_migrate: teach how to format ref names

This commit is contained in:
Taylor Blau 2017-06-09 17:38:59 -06:00
parent d557056af4
commit 2aeb148284

@ -2,6 +2,7 @@ package commands
import (
"path/filepath"
"strings"
"github.com/git-lfs/git-lfs/errors"
"github.com/git-lfs/git-lfs/git"
@ -28,6 +29,23 @@ func getObjectDatabase() (*odb.ObjectDatabase, error) {
return odb.FromFilesystem(filepath.Join(dir, "objects"))
}
// formatRefName returns the fully-qualified name for the given Git reference
// "ref".
func formatRefName(ref *git.Ref, remote string) string {
var name []string
switch ref.Type {
case git.RefTypeRemoteBranch:
name = []string{"refs", "remotes", remote, ref.Name}
case git.RefTypeRemoteTag:
name = []string{"refs", "tags", ref.Name}
default:
return ref.Name
}
return strings.Join(name, "/")
}
// currentRefToMigrate returns the fully-qualified name of the currently
// checked-out reference, or an error if the reference's type was not a local
// branch.