Skip to content

Commit 0234bd5

Browse files
authored
Merge pull request #51 from mxstack/maurits-git-clone-depth-env
Support environment variable GIT_CLONE_DEPTH.
2 parents 0c3a398 + a31ac07 commit 0234bd5

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 4.0.4 (unreleased)
44

5+
- Support environment variable `GIT_CLONE_DEPTH` for setting a default git depth for all checkouts. Useful for CI.
6+
[maurits]
7+
58
- Fix #47: Do not add packages with capital names uncommented at the bottom ignore list when checked out.
69
[petschki]
710

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ True by default, unless `default-use` in the general settings is false.
254254
When false, the source is not checked out,
255255
and the version for this package is not overridden.
256256

257+
#### `depth`
258+
259+
For `git` only.
260+
This is used to set the git clone depth.
261+
This is not set by default: you get a full clone.
262+
You can set environment variable `GIT_CLONE_DEPTH=1` to set a default git depth for all checkouts. This is useful for CI.
263+
257264
#### `submodules`
258265

259266
There are 3 different options:

src/mxdev/vcs/git.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
logger = common.logger
12+
GIT_CLONE_DEPTH = os.getenv("GIT_CLONE_DEPTH")
1213

1314

1415
class GitError(common.WCError):
@@ -151,8 +152,8 @@ def git_checkout(self, **kwargs) -> typing.Union[str, None]:
151152
update_git_submodules = self.source.get("submodules", kwargs["submodules"])
152153
if update_git_submodules == "recursive":
153154
args.append("--recurse-submodules")
154-
if "depth" in self.source:
155-
args.extend(["--depth", self.source["depth"]])
155+
if "depth" in self.source or GIT_CLONE_DEPTH:
156+
args.extend(["--depth", self.source.get("depth", GIT_CLONE_DEPTH)])
156157
if "branch" in self.source:
157158
args.extend(["-b", self.source["branch"]])
158159
args.extend([url, path])

0 commit comments

Comments
 (0)