Skip to content

Commit 1665b0a

Browse files
committed
add fix to support git<2.36 (conan-io#18501)
1 parent fa8cebf commit 1665b0a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

conan/tools/scm/git.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,15 @@ def commit_in_remote(self, commit, remote="origin"):
120120
self.run(f"fetch {remote} --refetch --dry-run {commit}")
121121
return True
122122
except (Exception,):
123-
# Don't raise an error because the fetch could fail for many more reasons than the branch.
124-
return False
123+
# For example, if using an older git<2.36, see
124+
# https://github.com/conan-io/conan/issues/18470, then lets try the old approach
125+
try:
126+
# This will raise if commit not present.
127+
self.run("fetch {} --dry-run --depth=1 {}".format(remote, commit))
128+
return True
129+
except (Exception,):
130+
# Don't raise an error because it could fail for many more reasons.
131+
return False
125132

126133
def is_dirty(self, repository=False):
127134
"""

0 commit comments

Comments
 (0)