Skip to content

Conversation

SaschaSchwarze0
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 commented May 11, 2025

Changes

Fixes #1874

When providing a commit sha as revision of a Git source, then we always performed a git clone --no-checkout followed by a git checkout COMMIT_SHA. By doing that, we performed a full history clone and therefore ignored the depth provided by the user.

In case the commit sha is a full commit sha, we can actually provide it with git clone --revision COMMIT_SHA and then also honor the deptch. For a short commit sha, this is not working, there we must still clone the full history to be able to checkout the short sha afterwards.

However, our ubi9-based images do not contain a Git binary that is new enough to support the --revision flag:

2025/05/11 09:34:31 /usr/bin/git -c safe.directory=/workspace/source clone --quiet --no-tags --revision 0be20591d7096bef165949c22f6059f5d8eb6a85 --depth 1 -- https://github.com/shipwright-io/sample-nodejs /workspace/source
2025/05/11 09:34:31 error: unknown option `revision'

Therefore, that optimized approach is only used when --revision is available.

The existing unit tests cover both cases (full and short sha) already.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

When specifying a Git source with a revision value which is a full commit SHA, then the source step now clones the repository at that point with the provided `depth` (default 1). Previously, when the revision was a commit SHA, it has always cloned the full history. This continues to be the case when you provide a short commit SHA. Note that this new approach is only used if Git supports the `revision` flag on `git clone`. This is not the case with the ubi9-based images that Shipwright provides.

@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.16.0 milestone May 11, 2025
@SaschaSchwarze0 SaschaSchwarze0 added the kind/bug Categorizes issue or PR as related to a bug. label May 11, 2025
@openshift-ci openshift-ci bot added the release-note Label for when a PR has specified a release note label May 11, 2025
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 11, 2025
@openshift-ci openshift-ci bot requested review from karanibm6 and qu1queee May 11, 2025 09:24
@SaschaSchwarze0 SaschaSchwarze0 force-pushed the sascha-depth-commit-sha branch 2 times, most recently from 3f53e14 to 9e00da9 Compare May 11, 2025 13:16
…ports --revision, provide it with the git clone command and honor the depth

Signed-off-by: Sascha Schwarze <[email protected]>
@SaschaSchwarze0 SaschaSchwarze0 force-pushed the sascha-depth-commit-sha branch from 9e00da9 to 00024dd Compare May 15, 2025 12:36
Copy link
Contributor

@qu1queee qu1queee left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 16, 2025
Copy link
Contributor

openshift-ci bot commented May 16, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qu1queee

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 16, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 9d90419 into shipwright-io:main May 16, 2025
19 checks passed
@SaschaSchwarze0 SaschaSchwarze0 deleted the sascha-depth-commit-sha branch August 28, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] Inconsistent History Behavior with Git Source
2 participants