Skip to content

Commit ce6ee78

Browse files
committed
fix: do not auto-set git shallow clones if a tag/commit is pinned
This generates an error later
1 parent e9ffc7b commit ce6ee78

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/autobuild/import/git.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,18 @@ def initialize(repository, branch = nil, options = {})
179179
with_submodules: false,
180180
fingerprint_mode: Git.default_fingerprint_mode,
181181
single_branch: Git.single_branch?,
182-
shallow: Git.shallow?
182+
shallow: nil
183183
)
184+
if gitopts[:shallow].nil? && Git.shallow?
185+
# Support for shallow clones is limited ... do not auto-set it
186+
# if we are in conditions where it will generate an error later
187+
gitopts[:shallow] =
188+
if gitopts[:tag]
189+
gitopts[:single_branch]
190+
else
191+
!gitopts[:commit]
192+
end
193+
end
184194

185195
if gitopts[:branch] && branch
186196
raise ConfigException, "git branch specified with both the option hash "\
@@ -1303,8 +1313,11 @@ def validate_shallow(package)
13031313
return false
13041314
end
13051315
if tag && !single_branch?
1306-
Autoproj.warn "#{package.name}: "\
1307-
"Cannot pin a tag while doing a shallow clone"
1316+
Autoproj.warn(
1317+
"#{package.name}: "\
1318+
"Cannot pin a tag while doing a shallow clone " \
1319+
"if single_branch is not set"
1320+
)
13081321
return false
13091322
end
13101323
if @remote_branch

0 commit comments

Comments
 (0)