gitsrht-update-hook: include branch name in job tags
This allows having a per-branch filter for build jobs. Use-cases include a build badge which only displays status for the default branch, or a getting the latest build artifacts only for the default branch.
This commit is contained in:
parent
be6100f36c
commit
163edba401
|
@ -320,6 +320,7 @@ func postUpdate() {
|
||||||
RepoName: dbinfo.RepoName,
|
RepoName: dbinfo.RepoName,
|
||||||
Repository: repo,
|
Repository: repo,
|
||||||
Visibility: dbinfo.Visibility,
|
Visibility: dbinfo.Visibility,
|
||||||
|
Ref: refname,
|
||||||
}
|
}
|
||||||
results, err := SubmitBuild(submitter)
|
results, err := SubmitBuild(submitter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -67,6 +67,8 @@ type BuildSubmitter interface {
|
||||||
GetRepoName() string
|
GetRepoName() string
|
||||||
// Get the name of the repository owner
|
// Get the name of the repository owner
|
||||||
GetOwnerName() string
|
GetOwnerName() string
|
||||||
|
// Get the job tags to use for this commit
|
||||||
|
GetJobTags() []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SQL notes
|
// SQL notes
|
||||||
|
@ -86,6 +88,7 @@ type GitBuildSubmitter struct {
|
||||||
RepoName string
|
RepoName string
|
||||||
Repository *git.Repository
|
Repository *git.Repository
|
||||||
Visibility string
|
Visibility string
|
||||||
|
Ref string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (submitter GitBuildSubmitter) FindManifests() (map[string]string, error) {
|
func (submitter GitBuildSubmitter) FindManifests() (map[string]string, error) {
|
||||||
|
@ -231,6 +234,14 @@ func (submitter GitBuildSubmitter) GetCommitNote() string {
|
||||||
commitUrl, submitter.Commit.Author.Email)
|
commitUrl, submitter.Commit.Author.Email)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (submitter GitBuildSubmitter) GetJobTags() []string {
|
||||||
|
tags := []string{submitter.GetRepoName(), "commits"}
|
||||||
|
if strings.HasPrefix(submitter.Ref, "refs/heads/") {
|
||||||
|
tags = append(tags, strings.TrimPrefix(submitter.Ref, "refs/heads/"))
|
||||||
|
}
|
||||||
|
return tags
|
||||||
|
}
|
||||||
|
|
||||||
func (submitter GitBuildSubmitter) GetCloneUrl() string {
|
func (submitter GitBuildSubmitter) GetCloneUrl() string {
|
||||||
if submitter.Visibility == "PRIVATE" {
|
if submitter.Visibility == "PRIVATE" {
|
||||||
origin := strings.ReplaceAll(submitter.GitOrigin, "http://", "")
|
origin := strings.ReplaceAll(submitter.GitOrigin, "http://", "")
|
||||||
|
@ -329,7 +340,7 @@ func SubmitBuild(submitter BuildSubmitter) ([]BuildSubmission, error) {
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
}{
|
}{
|
||||||
Manifest: yaml,
|
Manifest: yaml,
|
||||||
Tags: []string{submitter.GetRepoName(), "commits", name},
|
Tags: append(submitter.GetJobTags(), name),
|
||||||
Note: submitter.GetCommitNote(),
|
Note: submitter.GetCommitNote(),
|
||||||
}
|
}
|
||||||
bodyBytes, err := json.Marshal(&submission)
|
bodyBytes, err := json.Marshal(&submission)
|
||||||
|
|
Loading…
Reference in New Issue