# Git Commit<no value>
// <!-- Required for asciidoctor -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
:toclevels: 4

[cols="1^,1^,1^",options=header]
|===
| source | condition | target
| &#10004; | &#10004; | &#10008;
|===

The Git Commit "source" returns the latest commit hash referenced by a Git branch.

The Git Commit "condition" checks that a commit exists in a repository.
The commit hash defaults to the source output and can be overridden with `spec.hash`.
Abbreviated hashes are supported.

The target stage is not supported because commit hashes are immutable values.

== Repository selection

Both the source and the condition select a repository in the following order:

. The repository configured by `spec.url` is cloned.
. Otherwise, `spec.path` selects an existing local repository.
. Otherwise, the working directory from `scmid` is used.

When `spec.branch` is omitted, the current `HEAD` commit is returned.
When it is set, Updatecli resolves the local branch first and then its `origin` remote-tracking branch.
The lookup does not check out the branch or modify the working tree.

== Parameters

{{< resourceparameters "sources" "gitcommit" >}}

[NOTE]
====
YAML parses an unquoted all-digit value as a number.
Quote `spec.hash` when the commit hash only contains digits.
====

== Example

The following manifest shows SCM, URL, and local-path inputs.

[source,yaml]
----
# updatecli.yaml
{{<include "assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml">}}
----
