sourceconditiontarget

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:

  1. The repository configured by spec.url is cloned.

  2. Otherwise, spec.path selects an existing local repository.

  3. 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

NameTypeDescriptionRequired
branchstring

Branch specifies the branch whose latest commit hash is returned.

compatible:

  • source

default: The repository’s current HEAD branch.

depthinteger

Depth limits the number of commits fetched from the Git repository.

compatible:

  • source
  • condition

default: 0 (no limit)

hashstring

Hash specifies the commit hash checked by the condition.

compatible:

  • condition

default: The source output.

passwordstring

Password specifies the password used with the HTTP protocol.

compatible:

  • source
  • condition
pathstring

Path specifies a local Git repository path.

compatible:

  • source
  • condition

remarks:

  • Path overrides the working directory provided by an SCM configuration.
urlstring

URL specifies the Git repository URL to clone.

compatible:

  • source
  • condition

example:

  • git@github.com:updatecli/updatecli.git
  • https://github.com/updatecli/updatecli.git

remarks:

  • URL overrides both Path and the working directory provided by an SCM configuration.
usernamestring

Username specifies the username used with the HTTP protocol.

compatible:

  • source
  • condition
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.

# updatecli.yaml
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

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