From c0668755e21864d441cd05eef08196c99526ea8c Mon Sep 17 00:00:00 2001 From: ihopenre-eng <247072151+ihopenre-eng@users.noreply.github.com> Date: Thu, 16 Jul 2026 09:30:50 +0700 Subject: [PATCH 1/2] docs: add Git commit resource guide Signed-off-by: ihopenre-eng <247072151+ihopenre-eng@users.noreply.github.com> --- .../resources/gitcommit/updatecli.yaml | 28 ++++++++++ .../en/docs/plugins/resource/gitCommit.adoc | 53 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml create mode 100644 content/en/docs/plugins/resource/gitCommit.adoc diff --git a/assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml b/assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml new file mode 100644 index 000000000..872339502 --- /dev/null +++ b/assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml @@ -0,0 +1,28 @@ +scms: + application: + kind: git + spec: + branch: main + url: https://github.com/example/application.git + +sources: + from-scm: + name: Get the latest commit from the configured SCM + kind: gitcommit + scmid: application + spec: + branch: main + + from-url: + name: Get the latest commit from a Git URL + kind: gitcommit + spec: + branch: main + depth: 1 + url: https://github.com/example/application.git + + from-path: + name: Get the latest commit from a local repository + kind: gitcommit + spec: + path: ./application diff --git a/content/en/docs/plugins/resource/gitCommit.adoc b/content/en/docs/plugins/resource/gitCommit.adoc new file mode 100644 index 000000000..40dc20823 --- /dev/null +++ b/content/en/docs/plugins/resource/gitCommit.adoc @@ -0,0 +1,53 @@ +--- +title: "Git Commit" +description: "Retrieve the latest commit hash from a Git branch" +lead: "kind: gitcommit" +date: 2026-07-16T09:30:00+07:00 +draft: false +images: [] +menu: + docs: + parent: "plugin-resource" +toc: true +plugins: + - source +--- +// +: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 +| ✔ | ✘ | ✘ +|=== + +The Git Commit resource returns the latest commit hash referenced by a Git branch. +It is source-only because commit hashes are immutable values. + +== Repository selection + +The source selects 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" >}} + +== Example + +The following manifest shows SCM, URL, and local-path inputs. + +[source,yaml] +---- +# updatecli.yaml +{{}} +---- From a527cd49c12fa64e1b0ec196f0a89e7de7a8ffb9 Mon Sep 17 00:00:00 2001 From: ihopenre-eng <247072151+ihopenre-eng@users.noreply.github.com> Date: Fri, 17 Jul 2026 16:06:27 +0700 Subject: [PATCH 2/2] docs: document the gitcommit condition Signed-off-by: ihopenre-eng <247072151+ihopenre-eng@users.noreply.github.com> --- .../resources/gitcommit/updatecli.yaml | 15 ++++++++++++++ .../en/docs/plugins/resource/gitCommit.adoc | 20 +++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml b/assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml index 872339502..22510fefd 100644 --- a/assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml +++ b/assets/code_example/docs/plugins/resources/gitcommit/updatecli.yaml @@ -26,3 +26,18 @@ sources: kind: gitcommit spec: path: ./application + +conditions: + exists-in-scm: + name: Check that the source commit exists in the configured SCM + kind: gitcommit + scmid: application + sourceid: from-scm + + pinned-commit: + name: Check that a pinned commit exists in the repository + kind: gitcommit + disablesourceinput: true + spec: + url: https://github.com/example/application.git + hash: 69619610a3fac402931709dfbe89d113041c8776 diff --git a/content/en/docs/plugins/resource/gitCommit.adoc b/content/en/docs/plugins/resource/gitCommit.adoc index 40dc20823..eed12c087 100644 --- a/content/en/docs/plugins/resource/gitCommit.adoc +++ b/content/en/docs/plugins/resource/gitCommit.adoc @@ -11,6 +11,7 @@ menu: toc: true plugins: - source + - condition --- // :toc: @@ -20,15 +21,20 @@ plugins: [cols="1^,1^,1^",options=header] |=== | source | condition | target -| ✔ | ✘ | ✘ +| ✔ | ✔ | ✘ |=== -The Git Commit resource returns the latest commit hash referenced by a Git branch. -It is source-only because commit hashes are immutable values. +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 -The source selects a repository in the following order: +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. @@ -42,6 +48,12 @@ The lookup does not check out the branch or modify the working tree. {{< 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.