Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ configured branch, use `./git-external clone`.
url = "${ibrvsscloud}/foo"
path = "foo"
vcs = none
- `script = none`: Execute a script after cloning the external
- `script = none`: Execute a script located at repository root after cloning the external. Note: not supported on Windows (including git-bash).

[external "foo"]
script = run.sh
Expand All @@ -109,6 +109,13 @@ configured branch, use `./git-external clone`.
...
updateArgs = --sparse

- `sparseCheckout`: Enable and configure sparse checkout. If this option is not present or is empty, sparse checkout is disabled. Note, `--sparse` option to `cloneArgs` or `updateArgs` is not required for this to work.

[external "foo"]
...
sparseCheckout = "bar baz"


## Overrides

You can overide the settings for externals by putting an external
Expand Down
17 changes: 16 additions & 1 deletion bin/git-external
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ class GitExternal:
ret = cur_branch.stdout.decode().strip()
return ret or None

def update_sparse_checkout(self, repo, path, config):
"""Updates the current set of sparse checkouts"""
sparse_checkout = get_args(config, "sparseCheckout")
cur_dir = os.curdir
os.chdir(path)
if sparse_checkout:
log.info(f"[{repo}] Setting sparse-checkout to {sparse_checkout}")
cmd = ["git", "sparse-checkout", "set"] + sparse_checkout
else:
log.info(f"[{repo}] Sparse checkout not in use, disabled")
cmd = ["git", "sparse-checkout", "disable"]
check_call(cmd)
os.chdir(cur_dir)

def init_or_update(self, recursive=True, only=None, external=None):
"""Init or update all repositories in self.configurations.

Expand Down Expand Up @@ -355,6 +369,7 @@ class GitExternal:
opts = get_args(config, "updateArgs")
log.info(f"[{repo}] Updating Git external, {opts}")
check_call(["git", "pull", "--ff-only"] + opts, cwd=path)
self.update_sparse_checkout(repo, path, config)
elif cur_branch is None:
log.warning(f"[{repo}] Skipping update, detached HEAD")
else:
Expand Down Expand Up @@ -407,7 +422,7 @@ class GitExternal:
cmd = ["git", "clone"] + opts + [config["url"], path]
print(" ".join(cmd))
check_call(cmd)

self.update_sparse_checkout(repo, path, config)
cur_branch = self.get_branch_name(path)
branch = config.get('branch') or "master"
if cur_branch != branch:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
],
zip_safe=False,
scripts=['bin/git-external'],
python_requires='>=3.6'
python_requires='>=3.7'
)