From f9145cefe08d8fbd8e7a99038f5bc9c57e10b81b Mon Sep 17 00:00:00 2001 From: Zaki Shaikh Date: Wed, 5 Feb 2025 21:39:54 +0530 Subject: [PATCH] Clearification about GitOps command execution on pushed commits in docs it was not specified that GitOps command on pushed commit only works on latest HEAD commit and does not trigger PipelineRun if sent on older commits. Signed-off-by: Zaki Shaikh --- docs/content/docs/guide/gitops_commands.md | 4 +++- pkg/provider/github/github.go | 2 +- pkg/provider/github/parse_payload_test.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/content/docs/guide/gitops_commands.md b/docs/content/docs/guide/gitops_commands.md index eca9abc26..ab74df474 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. If a user specifies commands like `/retest` or `/test` without specifying branch name in a comment on branch, the test will automatically be performed on the **default branch** (e.g. main, master etc.) 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 1eef4ae95..4e442e482 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 {