Skip to content

Commit

Permalink
Merge pull request #50 from maryamklabib/shallowclone
Browse files Browse the repository at this point in the history
Adds optional depth parameter for specifying the number of git commits
  • Loading branch information
vito authored Aug 1, 2019
2 parents 8ee75f1 + 5b7f37d commit df77259
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ filed named `.gitkeep`. Finally, create individual locks by making an empty file
retrying to acquire a lock or release a lock. The default is 10 seconds.
Valid values: `60s`, `90m`, `1h`.
### Example
Fetching a repo with only 100 commits of history:
``` yaml
- get: source-code
params: {depth: 100}
```

## Behavior

Expand All @@ -83,13 +91,18 @@ given, the ref for `HEAD` is returned.

### `in`: Fetch an acquired lock.


Outputs 2 files:

* `metadata`: Contains the contents of whatever was in your lock file. This is
useful for environment configuration settings.

* `name`: Contains the name of lock that was acquired.

#### Parameters

* `depth`: *Optional.* If a positive integer is given, *shallow* clone the
repository using the `--depth` option.

### `out`: Acquire, release, add, or remove a lock.

Expand Down
8 changes: 7 additions & 1 deletion assets/in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ uri=$(jq -r '.source.uri // ""' < $payload)
branch=$(jq -r '.source.branch // ""' < $payload)
pool_name=$(jq -r '.source.pool // ""' < $payload)
ref=$(jq -r '.version.ref // "HEAD"' < $payload)
depth=$(jq -r '(.params.depth // 0)' < $payload)

if [ -z "$uri" ]; then
config_errors="${config_errors}invalid payload (missing uri)\n"
Expand All @@ -62,7 +63,12 @@ if [ -n "$branch" ]; then
branchflag="--branch $branch"
fi

git clone --single-branch $uri $branchflag $destination
depthflag=""
if test "$depth" -gt 0 2> /dev/null; then
depthflag="--depth $depth"
fi

git clone --single-branch $depthflag $uri $branchflag $destination

cd $destination

Expand Down

0 comments on commit df77259

Please sign in to comment.