Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds optional depth parameter for specifying the number of git commits #50

Merged
merged 3 commits into from
Aug 1, 2019
Merged
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
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