mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
feat: add option to specify git remote name (#1104)
fixes https://github.com/nektos/act/issues/1099 fixes https://github.com/nektos/act/issues/983 Signed-off-by: Ryan <me@hackerc.at> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
baaf0c58b2
commit
19cddfbddd
6 changed files with 15 additions and 7 deletions
|
@ -142,8 +142,12 @@ func findGitPrettyRef(head, root, sub string) (string, error) {
|
|||
}
|
||||
|
||||
// FindGithubRepo get the repo
|
||||
func FindGithubRepo(file string, githubInstance string) (string, error) {
|
||||
url, err := findGitRemoteURL(file)
|
||||
func FindGithubRepo(file, githubInstance, remoteName string) (string, error) {
|
||||
if remoteName == "" {
|
||||
remoteName = "origin"
|
||||
}
|
||||
|
||||
url, err := findGitRemoteURL(file, remoteName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -151,7 +155,7 @@ func FindGithubRepo(file string, githubInstance string) (string, error) {
|
|||
return slug, err
|
||||
}
|
||||
|
||||
func findGitRemoteURL(file string) (string, error) {
|
||||
func findGitRemoteURL(file, remoteName string) (string, error) {
|
||||
gitDir, err := findGitDirectory(file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -162,7 +166,7 @@ func findGitRemoteURL(file string) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
remote, err := gitconfig.GetSection("remote \"origin\"")
|
||||
remote, err := gitconfig.GetSection(fmt.Sprintf(`remote "%s"`, remoteName))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue