From 9e400725321ea106eae606a1b69c46b264b31ba0 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Wed, 19 Jun 2024 18:33:59 +0800 Subject: [PATCH] feat: updated ref name for git remote branches --- vcs/git.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/vcs/git.go b/vcs/git.go index 11267a472..0518d7fee 100644 --- a/vcs/git.go +++ b/vcs/git.go @@ -550,21 +550,27 @@ func (c *GitClient) GetRemoteRefs(remoteName string) (gitRefs []GitRef, err erro for _, ref := range refs { // ref type var refType string + var gitRef *GitRef if strings.HasPrefix(ref.Name().String(), "refs/heads") { refType = GitRefTypeBranch + gitRef = &GitRef{ + Type: refType, + Name: remoteName + "/" + ref.Name().Short(), + FullName: ref.Name().String(), + Hash: ref.Hash().String(), + } } else if strings.HasPrefix(ref.Name().String(), "refs/tags") { refType = GitRefTypeTag + gitRef = &GitRef{ + Type: refType, + Name: ref.Name().Short(), + FullName: ref.Name().String(), + Hash: ref.Hash().String(), + } } else { continue } - - // add to branches - gitRefs = append(gitRefs, GitRef{ - Type: refType, - Name: ref.Name().Short(), - FullName: ref.Name().String(), - Hash: ref.Hash().String(), - }) + gitRefs = append(gitRefs, *gitRef) } // logs without tags