feat: add commit-tag result to git-clone - #129
Conversation
Adds a new 'commit-tag' result that resolves to the git tag pointing at the fetched commit, falling back to 'git describe --tags --always' or 'no-tag' when no tag is reachable. Requires depth=0 (or a depth large enough to include the tagged commit) for reliable resolution on shallow clones. Manually verified against kelseyhightower/nocode@1.0.0 for both the Task and StepAction variants. Signed-off-by: Xavier Alonso Llauca Uchupailla <xllauca@mail.ru>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new commit-tag result to the git-clone Tekton Task (and its generated StepAction) so downstream Tasks can use the Git tag associated with the fetched commit (or a fallback).
Changes:
- Add
commit-tagresult to the Task and StepAction definitions and populate it during the clone step. - Document the new result in the Task README.
- Add TaskRun fixtures for both Task and StepAction test manifests to exercise
revision: 1.0.0withdepth: "0".
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| task/git-clone/git-clone.yaml | Adds the commit-tag result and computes/writes it in the clone step script. |
| stepaction/git-clone/git-clone.yaml | Propagates the generated StepAction result and script logic for commit-tag. |
| task/git-clone/README.md | Documents the new commit-tag result. |
| task/git-clone/tests/run.yaml | Adds a TaskRun fixture targeting tag-based revision + full depth. |
| stepaction/git-clone/tests/run.yaml | Adds a StepAction TaskRun fixture targeting tag-based revision + full depth. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| git fetch origin 'refs/tags/*:refs/tags/*' --depth=1 2>/dev/null || git fetch origin 'refs/tags/*:refs/tags/*' 2>/dev/null || true | ||
| COMMIT_TAG="$(git tag --points-at HEAD | head -n1)" | ||
| if [ -z "${COMMIT_TAG}" ] ; then | ||
| COMMIT_TAG="$(git describe --tags --always 2>/dev/null || echo "no-tag")" | ||
| fi |
| git fetch origin 'refs/tags/*:refs/tags/*' --depth=1 2>/dev/null || git fetch origin 'refs/tags/*:refs/tags/*' 2>/dev/null || true | ||
| COMMIT_TAG="$(git tag --points-at HEAD | head -n1)" | ||
| if [ -z "${COMMIT_TAG}" ] ; then | ||
| COMMIT_TAG="$(git describe --tags --always 2>/dev/null || echo "no-tag")" | ||
| fi |
| - description: The Git tag pointing at the fetched commit, or a fallback (git describe / shortsha). | ||
| name: commit-tag |
| | `commit` | The precise commit SHA that was fetched | | ||
| | `url` | The precise URL that was fetched | | ||
| | `committer-date` | The epoch timestamp of the fetched commit | | ||
| | `commit-tag` | The Git tag pointing at the fetched commit, or a fallback (git describe / shortsha) | |
Changes
Adds a new
commit-tagresult to thegit-cloneTask and StepAction, exposingthe git tag pointing at the fetched commit for use by downstream Tasks (e.g.
image tagging in CI pipelines).
Behavior:
commit-tagis that tag.git describe --tags --always."no-tag".Depth requirement: tag resolution requires a non-shallow clone. With the
default
depth: "1", the tagged commit may be outside the shallow fetchwindow, causing
commit-tagto resolve tono-tageven when a tag existsupstream. Consumers needing reliable resolution should set
depth: "0"(orlarge enough to include the tagged commit).
Testing: added fixtures to both
task/git-clone/tests/run.yamlandstepaction/git-clone/tests/run.yaml. Per existing test infra(
test/e2e-tests.sh), these only validate that the TaskRun reachesSucceeded, not result content — manually verified content correctnessagainst
kelseyhightower/nocode@1.0.0for both variants (Task andStepAction), confirming
commit-tag: 1.0.0in both cases.Submitter Checklist
Release Notes