diff --git a/docs/content/docs/guide/gitops_commands.md b/docs/content/docs/guide/gitops_commands.md index eca9abc26..fdf8b2fcb 100644 --- a/docs/content/docs/guide/gitops_commands.md +++ b/docs/content/docs/guide/gitops_commands.md @@ -46,13 +46,15 @@ For restarting all pipeline runs: For restarting a specific pipeline run: 2. Use `/retest ` or `/test ` within your commit message. Replace `` with the specific name of the pipeline run you want to restart. +The GitOps command triggers a PipelineRun only on the latest commit (HEAD) of the branch and does not work on older commits. + **Note:** When executing `GitOps` commands on a commit that exists in multiple branches within a push request, the branch with the latest commit will be used. This means: -1. If a user specifies commands like `/retest` or `/test` without any argument in a comment on a branch, the test will automatically be performed on the **main** branch. +1. When a user comments with commands like `/retest` or `/test` on a branch without specifying a branch name, the test will automatically run on the **default branch** (e.g. main, master) of the repository. Examples: 1. `/retest` diff --git a/pkg/provider/github/github.go b/pkg/provider/github/github.go index ab0f550df..d7c91bb4e 100644 --- a/pkg/provider/github/github.go +++ b/pkg/provider/github/github.go @@ -600,5 +600,5 @@ func (v *Provider) isBranchContainsCommit(ctx context.Context, runevent *info.Ev if branchInfo.Commit.GetSHA() == runevent.SHA { return nil } - return fmt.Errorf("provided branch %s does not contains sha %s", branchName, runevent.SHA) + return fmt.Errorf("provided SHA %s is not the HEAD commit of the branch %s", runevent.SHA, branchName) } diff --git a/pkg/provider/github/parse_payload_test.go b/pkg/provider/github/parse_payload_test.go index 92c852ab1..969aaebed 100644 --- a/pkg/provider/github/parse_payload_test.go +++ b/pkg/provider/github/parse_payload_test.go @@ -539,7 +539,7 @@ func TestParsePayLoad(t *testing.T) { shaRet: "samplePRshanew", targetPipelinerun: "dummy", wantedBranchName: "main", - wantErrString: "provided branch main does not contains sha samplePRshanew", + wantErrString: "provided SHA samplePRshanew is not the HEAD commit of the branch main", }, } for _, tt := range tests {