Fixes git references wrongly transmitted to the action run
This commit is contained in:
parent
9634d954d4
commit
9b225b56a9
3 changed files with 25 additions and 1 deletions
|
@ -5,6 +5,7 @@ package git
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
@ -61,3 +62,19 @@ func parseTags(refs []string) []string {
|
|||
}
|
||||
return results
|
||||
}
|
||||
|
||||
// ExpandRef expands any partial reference to its full form
|
||||
func (repo *Repository) ExpandRef(ref string) (string, error) {
|
||||
if strings.HasPrefix(ref, "refs/") {
|
||||
return ref, nil
|
||||
} else if strings.HasPrefix(ref, "tags/") || strings.HasPrefix(ref, "heads/") {
|
||||
return "refs/" + ref, nil
|
||||
} else if repo.IsTagExist(ref) {
|
||||
return TagPrefix + ref, nil
|
||||
} else if repo.IsBranchExist(ref) {
|
||||
return BranchPrefix + ref, nil
|
||||
} else if repo.IsCommitExist(ref) {
|
||||
return ref, nil
|
||||
}
|
||||
return "", fmt.Errorf("could not expand reference '%s'", ref)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue