diff options
author | Klaus Aehlig <aehlig@google.com> | 2018-05-24 02:59:03 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-24 03:00:13 -0700 |
commit | 7458a5f5415f8d3e71a29a2c0b8338296c111c6c (patch) | |
tree | 0064aa8131039e647aafd971727d562d9580560b /tools | |
parent | c1fc17a67e78625415620ddb4ff5696d37e6e291 (diff) |
git.bzl: fall back to full clone if shallow options are not supported
The `--shallow-since` option of git was introduced only in version 2.11 of git. However,
some widely used distributions ship older versions of git. So fall back to fully cloning
or fetching a repository if the respective shallow option is not know to the ambient git
command used.
Change-Id: I8f0aa0a12e294ff9cc8325975bd9333f6bf50939
PiperOrigin-RevId: 197863797
Diffstat (limited to 'tools')
-rw-r--r-- | tools/build_defs/repo/git.bzl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/build_defs/repo/git.bzl b/tools/build_defs/repo/git.bzl index 22026e873a..c522956ee4 100644 --- a/tools/build_defs/repo/git.bzl +++ b/tools/build_defs/repo/git.bzl @@ -46,10 +46,10 @@ set -ex ( cd {working_dir} && if ! ( cd '{dir_link}' && [[ "$(git rev-parse --git-dir)" == '.git' ]] ) >/dev/null 2>&1; then rm -rf '{directory}' '{dir_link}' - git clone {shallow} '{remote}' '{directory}' + git clone {shallow} '{remote}' '{directory}' || git clone '{remote}' '{directory}' fi cd '{directory}' - git reset --hard {ref} || (git fetch {shallow} origin {ref}:{ref} && git reset --hard {ref}) + git reset --hard {ref} || ((git fetch {shallow} origin {ref}:{ref} || git fetch origin {ref}:{ref}) && git reset --hard {ref}) git clean -xdf ) """.format( working_dir=ctx.path('.').dirname, |