Skip to content

Commit

Permalink
Fixing labels (appsody#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
Enrique Lacal authored and kylegc committed Oct 23, 2019
1 parent 4cc1982 commit ceacada
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions cmd/git_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,20 @@ func RunGitConfigLocalRemoteOriginURL(upstream string, dryrun bool) (string, err

upstreamStart := strings.Split(upstream, "/")[0]
kargs := []string{"config", "--local", "remote." + upstreamStart + ".url"}
return RunGit(kargs, dryrun)
remote, err := RunGit(kargs, dryrun)
if err != nil {
return remote, err
}

// Convert ssh remote to https
if strings.Contains(remote, "git@") {
remote = strings.Replace(remote, ":", "/", 1)
remote = strings.Replace(remote, "git@", "https://", 1)
}

remote = strings.Replace(remote, ".git", "", 1)

return remote, err
}

//RunGitLog issues git log
Expand Down Expand Up @@ -207,5 +220,7 @@ func RunGit(kargs []string, dryrun bool) (string, error) {
return "", errors.Errorf("git command failed: %s", string(kout[:]))
}
Debug.log("Command successful...")
return string(kout[:]), nil
result := string(kout[:])
result = strings.TrimRight(result, "\n")
return result, nil
}
4 changes: 2 additions & 2 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,11 @@ func getGitLabels(config *RootCommandConfig) (map[string]string, error) {
if gitInfo.RemoteURL != "" {
labels[ociKeyPrefix+"url"] = gitInfo.RemoteURL
labels[ociKeyPrefix+"documentation"] = gitInfo.RemoteURL
labels[ociKeyPrefix+"source"] = gitInfo.RemoteURL + "tree/" + gitInfo.Branch
labels[ociKeyPrefix+"source"] = gitInfo.RemoteURL + "/tree/" + gitInfo.Branch
}

var commitInfo = gitInfo.Commit
revisionKey := appsodyKeyPrefix + "revision"
revisionKey := ociKeyPrefix + "revision"
if commitInfo.SHA != "" {
labels[revisionKey] = commitInfo.SHA
if gitInfo.ChangesMade {
Expand Down

0 comments on commit ceacada

Please sign in to comment.