Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/omnibus/fetchers/git_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,15 @@ def cloned?
# @return [void]
#
def git_clone
retry_block("git clone", [CommandTimeout, CommandFailed]) do
git("clone#{" --recursive" if clone_submodules?} #{source_url} .")
retry_block("custom git clone", [CommandTimeout, CommandFailed]) do
log.info(log_key) { "Cloning repository #{source_url} at revision #{resolved_version}" }
git("init")
git("remote add origin #{source_url}")
git("fetch origin #{resolved_version}")
git("checkout #{resolved_version}")
if clone_submodules?
git("submodule update --init --recursive")
end
Copy link
Member

Choose a reason for hiding this comment

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

What about git clone --single-branch --branch <branch> ?

Copy link
Author

Choose a reason for hiding this comment

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

I think it doesn't work with revisions

Copy link
Member

@FlorentClarret FlorentClarret Jan 23, 2025

Choose a reason for hiding this comment

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

❯ git clone --single-branch --branch 7.61.0 git@github.com:DataDog/omnibus-ruby.git
Cloning into 'omnibus-ruby'...
remote: Enumerating objects: 15051, done.
remote: Counting objects: 100% (2139/2139), done.
remote: Compressing objects: 100% (311/311), done.
remote: Total 15051 (delta 1978), reused 1907 (delta 1828), pack-reused 12912 (from 2)
Receiving objects: 100% (15051/15051), 32.65 MiB | 16.85 MiB/s, done.
Resolving deltas: 100% (9421/9421), done.
Note: switching to 'd365e483ee05a13e55eeb5208d11452c5b65afbb'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Copy link
Member

Choose a reason for hiding this comment

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

ah it works with tags but not hashes 😢

end
end

Expand Down
Loading