Skip to content

feat(gitcommit): add Git commit source resource - #9609

Merged
olblak merged 6 commits into
updatecli:mainfrom
ihopenre-eng:feat/git-commit-source
Jul 18, 2026
Merged

feat(gitcommit): add Git commit source resource#9609
olblak merged 6 commits into
updatecli:mainfrom
ihopenre-eng:feat/git-commit-source

Conversation

@ihopenre-eng

@ihopenre-eng ihopenre-eng commented Jul 16, 2026

Copy link
Copy Markdown
Member

Fix #2052

Add a gitcommit resource. The source returns the latest commit hash for a Git branch; the condition checks that a commit exists in a repository. Both support repository URLs, local paths, and SCM working directories. Branch lookup resolves local and origin refs without checking out the branch or modifying the working tree.

The condition hash defaults to the source output and can be overridden with spec.hash; abbreviated hashes are resolved with the Git revision syntax.

The resource is registered in the pipeline mapping and includes an end-to-end manifest covering URL, path, and SCM inputs plus two condition scenarios.

Test

go test ./pkg/plugins/resources/gitcommit -count=1
go test ./pkg/plugins/utils/gitgeneric -run '^TestGetCommitHash$|^TestIsCommitExist$' -count=1
go test ./pkg/core/pipeline/resource -count=1
go vet ./pkg/plugins/resources/gitcommit ./pkg/plugins/utils/gitgeneric ./pkg/core/pipeline/resource

Additional Information

Checklist

Tradeoff

The target stage returns an explicit unsupported error because a commit hash is immutable. The condition checks commit existence, defaulting to the source output with spec.hash as an override.

Potential improvement

A future changelog implementation could expose commits between two source revisions.

Signed-off-by: ihopenre-eng <247072151+ihopenre-eng@users.noreply.github.com>
@olblak

olblak commented Jul 16, 2026

Copy link
Copy Markdown
Member

Thanks for the pullrequest, I'll try to find some time in the coming days to review it

Comment thread pkg/plugins/resources/gitcommit/condition.go Outdated
Comment thread pkg/plugins/resources/gitcommit/source.go
@olblak olblak added enhancement New feature or request resource-gitcommit labels Jul 17, 2026
@olblak

olblak commented Jul 17, 2026

Copy link
Copy Markdown
Member

I just gave a quick test and it works as expected thanks for the e2e tests.
I am happy to merge it as it is or wait for a condition if you are interested in it

@mergify

mergify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

The condition checks that a commit exists in the repository. The commit
hash defaults to the source output and can be overridden with spec.hash.
Repository selection follows the same order as the source: URL, path,
then SCM working directory. Abbreviated hashes are resolved with the
Git revision syntax.

Signed-off-by: ihopenre-eng <247072151+ihopenre-eng@users.noreply.github.com>
@ihopenre-eng

Copy link
Copy Markdown
Member Author

Thanks for testing it! I went ahead and added the condition in this PR (9b60f1d).

The condition checks that a commit exists in the repository: the commit hash defaults to the source output and can be overridden with spec.hash (abbreviated hashes are supported). Repository selection follows the same order as the source: spec.url, then spec.path, then the scmid working directory.

The e2e manifest now covers two condition scenarios — checking the source commit against the SCM working directory, and checking a pinned hash against a cloned URL — and the website documentation PR (updatecli/website#3563) is updated accordingly.

go test ./pkg/plugins/resources/gitcommit -count=1
go test ./pkg/plugins/utils/gitgeneric -run '^TestIsCommitExist$' -count=1
go run . diff --config e2e/updatecli.d/success.d/gitCommit.yaml

@olblak olblak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the pull request

@olblak
olblak enabled auto-merge (squash) July 18, 2026 11:25
@olblak
olblak merged commit d75ef14 into updatecli:main Jul 18, 2026
8 checks passed
@ihopenre-eng
ihopenre-eng deleted the feat/git-commit-source branch July 18, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request resource-gitcommit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Git Commit Source

2 participants