You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each commit in the pull request are processed individually as a
single commit before submitting to Gerrit repository. This option
allows you to preserve git history.
This requires `inputs.SUBMIT_SINGLE_COMMITS` to be set to 'true'
from the caller.
Remove extra inputs. Gerrit server and port and project has be read
from .gitreview file. Composite actions have a limitation on
the number of the inputs that can be passed to 10.
Update doc example with new feat options.
Signed-off-by: Anil Belur <[email protected]>
- name: Add comment to refrence the change-request on the pull-request
424
+
if: |
425
+
hashFiles('commit-sha.txt') != '' ||
426
+
(! startsWith(env.GERRIT_CHANGE_REQUEST_URL, ''))
345
427
uses: actions/github-script@v7
346
428
with:
347
429
result-encoding: string
348
430
retries: 3
349
431
retry-exempt-status-codes: 400,401
350
432
script: |
351
433
const output = `The pull-request PR-${{ env.PR_NUMBER }} is submitted to Gerrit [${{ inputs.ORGANIZATION }}](https://${{ env.GERRIT_SERVER }})! \n
352
-
To follow up on the change visit: [${{ env.GERRIT_CHANGE_REQUEST_NUMBER }}](${{ env.GERRIT_CHANGE_REQUEST_URL }}) \n \n
434
+
To follow up on the change visit: \n \n ${{ env.GERRIT_CHANGE_REQUEST_URL }} \n \n
353
435
NOTE: The pull-request PR-${{ env.PR_NUMBER }} will be closed, re-opening the pull-request will not update the same commit and may result in duplicate changes on Gerrit.`
Copy file name to clipboardExpand all lines: README.md
+30-13Lines changed: 30 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -14,26 +14,41 @@ The action extracts the commits from a GitHub pull-request and submits them to a
14
14
The action and workflow are written with bash scripts using well known Git SCM tools, gh, jq and git-review.
15
15
16
16
1. The action is triggered when a new pull request is created on a GitHub repository configured with the action.
17
-
2. Squash all the commits in the pull request into a single commit.
17
+
2. One of the below options can be used depending on the workflow followed by the community.
18
+
19
+
- Squash all the commits in the pull request into a single commit and use consolidate the commit titles and body into a single commit (Default).
20
+
- Squash all the commits in the pull request into a single commit and using the pull request title and body as the commit title and body (USE_PR_AS_COMMIT).
21
+
- Submit each commit as a separate single commit preserving the git history (SUBMIT_SINGLE_COMMITS).
22
+
18
23
3. Check for a Change-Id line in the pull request commit message. If it is not present, add the Change-Id to the commit. If the Change-Id is found in any of the commits, it will be reused along with the patch.
19
-
4. Create a Gerrit patch with the Change-Id, squashing all PR changes into a single commit.
20
-
5. Add a pull-request reference as a comment on the Gerrit change for committers or reviewers to refer to the source of change request.
21
-
6. Close the pull request once the Gerrit patch is submitted. A comment is added to the pull request with the URL to the change. Any updates will require the pull request to be reopened. Updates to the pull request are done with a force push, which triggers the workflows to ensure the change is resubmitted.
24
+
4. Add the Change-Id (and optionally squash changes into a single commit if required).
25
+
5. Add a pull-request and workflow run reference link as a comment on the Gerrit change that was created for committers or reviewers to back reference to the source of change request.
26
+
6. Add a comment to the pull request with the URL to the change. Any updates will require the pull request to be reopened and updates to the pull request must be done with a force push, which triggers the workflows to ensure the change is resubmitted.
27
+
7. Close the pull request once the Gerrit patch is submitted successfully.
22
28
23
29
## Features
24
30
25
-
### Use pull-request a commit message
31
+
### Use pull-request as a single squashed commit message
32
+
33
+
- Commits in a pull request are squashed into a single commit before submitting the change request to Gerrit. This is the default behavior shown in the caller workflow examples.
34
+
- Merge commits get filtered out.
35
+
- Here `inputs.SUBMIT_SINGLE_COMMITS` is set to 'false' by default.
36
+
37
+
### Use pull-request body and title in the commit message
26
38
27
-
- Commits in a pull request are squashed into a single commit before submitting the change request to Gerrit.
39
+
- The commit message title and body is extracted from the pull request body and title along with the change-Id and Signed-off-by lines. Commits are still squashed and while only the commit body and title are discarded.
40
+
- Requires setting `inputs.USE_PR_AS_COMMIT` to 'true'.
41
+
- This option is exclusive with `inputs.SUBMIT_SINGLE_COMMITS` and cannot be used together.
28
42
29
-
### Use pull-request a commit message
43
+
### Submit each commit as a separate single commit
30
44
31
-
- Set the commit message as pull request body and title along with the change-Id and Signed-off-by lines. Commit message are squashed and the commit body and tittle are discarded.
45
+
- Each commit in the pull request are processed individually as a single commit before submitting to Gerrit repository. This option allows you to preserve git history.
46
+
- Requires `inputs.SUBMIT_SINGLE_COMMITS` to be set to 'true' in the caller.
32
47
33
48
## Caveats - Future Improvements
34
49
35
-
-Commits in a pull request are submitted as independent change requests to Gerrit under the same topic.
36
-
- Code review comments on Gerrit will not be updated back on the pull request, requiring developers to follow up on the Gerrit change request URL.
50
+
-`inputs.SUBMIT_SINGLE_COMMITS` has not be tested extensively for handling large pull requests.
51
+
- Code review comments on Gerrit are not synchronized back to the pull request comment, therefore requires developers to follow up on the Gerrit change request URL. Rework through the recommended changes can be done by reopening the pull request and updating to the commits through a force push.
37
52
38
53
## Required Inputs
39
54
@@ -44,7 +59,8 @@ The action and workflow are written with bash scripts using well known Git SCM t
44
59
45
60
## Optional Inputs
46
61
47
-
-`USE_PR_AS_COMMIT`: Use commit body and tittle from pull-request (Default: false)
62
+
-`SUBMIT_SINGLE_COMMITS`: Submit one commit at a time to the Gerrit repository (Default: false)
63
+
-`USE_PR_AS_COMMIT`: Use commit body and title from pull-request (Default: false)
48
64
-`FETCH_DEPTH`: fetch-depth of the clone repo. (Default: 10)
49
65
-`GERRIT_PROJECT`: Gerrit project repository (Default read from .gitreview).
50
66
-`GERRIT_SERVER`: Gerrit server FQDN (Default read from .gitreview).
@@ -55,6 +71,7 @@ The action and workflow are written with bash scripts using well known Git SCM t
55
71
## Full Example Usage with Composite Action
56
72
57
73
Use the composite action as a step in the workflow for further processing.
74
+
Example workflow does not enable `SUBMIT_SINGLE_COMMITS` and `USE_PR_AS_COMMIT`
0 commit comments