Skip to content

feat: add commit-tag result to git-clone - #129

Open
xllauca wants to merge 1 commit into
tektoncd-catalog:mainfrom
xllauca:feat/commit-tag-result
Open

xllauca wants to merge 1 commit into
tektoncd-catalog:mainfrom
xllauca:feat/commit-tag-result

Conversation

@xllauca

@xllauca xllauca commented Jun 18, 2026

Copy link
Copy Markdown

Changes

Adds a new commit-tag result to the git-clone Task and StepAction, exposing
the git tag pointing at the fetched commit for use by downstream Tasks (e.g.
image tagging in CI pipelines).

Behavior:

  • If the fetched commit has a tag pointing directly at it, commit-tag is that tag.
  • Otherwise, falls back to git describe --tags --always.
  • If no tags exist at all, falls back to "no-tag".

Depth requirement: tag resolution requires a non-shallow clone. With the
default depth: "1", the tagged commit may be outside the shallow fetch
window, causing commit-tag to resolve to no-tag even when a tag exists
upstream. Consumers needing reliable resolution should set depth: "0" (or
large enough to include the tagged commit).

Testing: added fixtures to both task/git-clone/tests/run.yaml and
stepaction/git-clone/tests/run.yaml. Per existing test infra
(test/e2e-tests.sh), these only validate that the TaskRun reaches
Succeeded, not result content — manually verified content correctness
against kelseyhightower/nocode@1.0.0 for both variants (Task and
StepAction), confirming commit-tag: 1.0.0 in both cases.

Submitter Checklist

Release Notes

Add new `commit-tag` result to `git-clone` Task and StepAction, exposing the git tag pointing at the fetched commit (or a fallback) for downstream use.

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>
@tekton-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign vinamra28 after the PR has been reviewed.
You can assign the PR to them by writing /assign @vinamra28 in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 18, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: xllauca / name: Xavier Alonso Llauca Uchupailla (b61a687)

@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 18, 2026
@vdemeester
vdemeester requested a review from Copilot June 30, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-tag result 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.0 with depth: "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.

Comment on lines +255 to +259
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
Comment on lines +268 to +272
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
Comment on lines +120 to +121
- description: The Git tag pointing at the fetched commit, or a fallback (git describe / shortsha).
name: commit-tag
Comment thread task/git-clone/README.md
| `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) |
@vdemeester vdemeester self-assigned this Jul 1, 2026
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2026
@tekton-robot

Copy link
Copy Markdown

@xllauca: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants