mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
query and show commits by branch
This allows the same SHA to have different builds on different branches, each separately viewable. This is useful for expressing a "pipeline" in terms of branches, e.g. a commit starts on branch A and progress through B and C to master, with the build script switching on branch name. Previously viewing each build would arbitrarily choose which branch's commit to show.
This commit is contained in:
@@ -44,6 +44,32 @@ func TestGetCommit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCommitBranchHash(t *testing.T) {
|
||||
Setup()
|
||||
defer Teardown()
|
||||
|
||||
commit, err := database.GetCommitBranchHash("develop", "5f32ec7b08dfe3a097c1a5316de5b5069fb35ff9", 2)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if commit.ID != 5 {
|
||||
t.Errorf("Exepected ID %d, got %d", 5, commit.ID)
|
||||
}
|
||||
|
||||
if commit.Branch != "develop" {
|
||||
t.Errorf("Exepected Branch %s, got %s", "develop", commit.Branch)
|
||||
}
|
||||
|
||||
if commit.Hash != "5f32ec7b08dfe3a097c1a5316de5b5069fb35ff9" {
|
||||
t.Errorf("Exepected Hash %s, got %s", "5f32ec7b08dfe3a097c1a5316de5b5069fb35ff9", commit.Hash)
|
||||
}
|
||||
|
||||
if commit.Status != "Success" {
|
||||
t.Errorf("Exepected Status %s, got %s", "Success", commit.Status)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCommitHash(t *testing.T) {
|
||||
Setup()
|
||||
defer Teardown()
|
||||
|
||||
@@ -191,12 +191,22 @@ func Setup() {
|
||||
Gravatar: user1.Gravatar,
|
||||
Message: "commit message",
|
||||
}
|
||||
commit5 := Commit{
|
||||
RepoID: repo2.ID,
|
||||
Status: "Success",
|
||||
Hash: "5f32ec7b08dfe3a097c1a5316de5b5069fb35ff9",
|
||||
Branch: "develop",
|
||||
Author: user1.Email,
|
||||
Gravatar: user1.Gravatar,
|
||||
Message: "commit message",
|
||||
}
|
||||
|
||||
// create dummy commit data
|
||||
database.SaveCommit(&commit1)
|
||||
database.SaveCommit(&commit2)
|
||||
database.SaveCommit(&commit3)
|
||||
database.SaveCommit(&commit4)
|
||||
database.SaveCommit(&commit5)
|
||||
|
||||
// create dummy build data
|
||||
database.SaveBuild(&Build{CommitID: commit1.ID, Slug: "node_0.10", Status: "Success", Duration: 60})
|
||||
|
||||
Reference in New Issue
Block a user