mirror of
https://github.com/actions/checkout.git
synced 2026-03-07 08:51:46 +08:00
Compare commits
10 Commits
af6092afbf
...
63e06d4b32
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63e06d4b32 | ||
|
|
c2d88d3ecc | ||
|
|
1af3b93b68 | ||
|
|
2449f8bb0b | ||
|
|
220570c515 | ||
|
|
819730283a | ||
|
|
50ecf51910 | ||
|
|
72a87eaf9f | ||
|
|
9dceaac6c6 | ||
|
|
b0b939aaa5 |
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.1.6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set Node.js 24.x
|
- name: Set Node.js 24.x
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
|
|||||||
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@ -39,7 +39,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4.1.6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v3
|
uses: github/codeql-action/init@v3
|
||||||
|
|||||||
2
.github/workflows/licensed.yml
vendored
2
.github/workflows/licensed.yml
vendored
@ -9,6 +9,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Check licenses
|
name: Check licenses
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.1.6
|
- uses: actions/checkout@v6
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run licensed-check
|
- run: npm run licensed-check
|
||||||
@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checking out
|
- name: Checking out
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
- name: Publish
|
- name: Publish
|
||||||
id: publish
|
id: publish
|
||||||
uses: actions/publish-immutable-action@0.0.3
|
uses: actions/publish-immutable-action@0.0.3
|
||||||
|
|||||||
16
.github/workflows/test.yml
vendored
16
.github/workflows/test.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
- uses: actions/checkout@v4.1.6
|
- uses: actions/checkout@v6
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run format-check
|
- run: npm run format-check
|
||||||
@ -37,7 +37,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Basic checkout
|
# Basic checkout
|
||||||
- name: Checkout basic
|
- name: Checkout basic
|
||||||
@ -202,7 +202,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Basic checkout using git
|
# Basic checkout using git
|
||||||
- name: Checkout basic
|
- name: Checkout basic
|
||||||
@ -234,7 +234,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Basic checkout using git
|
# Basic checkout using git
|
||||||
- name: Checkout basic
|
- name: Checkout basic
|
||||||
@ -264,7 +264,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: localClone
|
path: localClone
|
||||||
|
|
||||||
@ -291,8 +291,8 @@ jobs:
|
|||||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||||
|
|
||||||
# needed to make checkout post cleanup succeed
|
# needed to make checkout post cleanup succeed
|
||||||
- name: Fix Checkout v4
|
- name: Fix Checkout v6
|
||||||
uses: actions/checkout@v4.1.6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: localClone
|
path: localClone
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: actions-checkout
|
path: actions-checkout
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/update-main-version.yml
vendored
2
.github/workflows/update-main-version.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
|||||||
# Note this update workflow can also be used as a rollback tool.
|
# Note this update workflow can also be used as a rollback tool.
|
||||||
# For that reason, it's best to pin `actions/checkout` to a known, stable version
|
# For that reason, it's best to pin `actions/checkout` to a known, stable version
|
||||||
# (typically, about two releases back).
|
# (typically, about two releases back).
|
||||||
- uses: actions/checkout@v4.1.6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Git config
|
- name: Git config
|
||||||
|
|||||||
2
.github/workflows/update-test-ubuntu-git.yml
vendored
2
.github/workflows/update-test-ubuntu-git.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Use `docker/login-action` to log in to GHCR.io.
|
# Use `docker/login-action` to log in to GHCR.io.
|
||||||
# Once published, the packages are scoped to the account defined here.
|
# Once published, the packages are scoped to the account defined here.
|
||||||
|
|||||||
@ -1,8 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## V6.0.0
|
||||||
|
* Persist creds to a separate file by @ericsciple in https://github.com/actions/checkout/pull/2286
|
||||||
|
* Update README to include Node.js 24 support details and requirements by @salmanmkc in https://github.com/actions/checkout/pull/2248
|
||||||
|
|
||||||
|
## V5.0.1
|
||||||
|
* Port v6 cleanup to v5 by @ericsciple in https://github.com/actions/checkout/pull/2301
|
||||||
|
|
||||||
## V5.0.0
|
## V5.0.0
|
||||||
* Update actions checkout to use node 24 by @salmanmkc in https://github.com/actions/checkout/pull/2226
|
* Update actions checkout to use node 24 by @salmanmkc in https://github.com/actions/checkout/pull/2226
|
||||||
|
|
||||||
|
## V4.3.1
|
||||||
|
* Port v6 cleanup to v4 by @ericsciple in https://github.com/actions/checkout/pull/2305
|
||||||
|
|
||||||
## V4.3.0
|
## V4.3.0
|
||||||
* docs: update README.md by @motss in https://github.com/actions/checkout/pull/1971
|
* docs: update README.md by @motss in https://github.com/actions/checkout/pull/1971
|
||||||
|
|||||||
39
README.md
39
README.md
@ -1,6 +1,6 @@
|
|||||||
[](https://github.com/actions/checkout/actions/workflows/test.yml)
|
[](https://github.com/actions/checkout/actions/workflows/test.yml)
|
||||||
|
|
||||||
# Checkout v6-beta
|
# Checkout v6
|
||||||
|
|
||||||
## What's new
|
## What's new
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
|
|
||||||
<!-- start usage -->
|
<!-- start usage -->
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
# Repository name with owner. For example, actions/checkout
|
# Repository name with owner. For example, actions/checkout
|
||||||
# Default: ${{ github.repository }}
|
# Default: ${{ github.repository }}
|
||||||
@ -128,6 +128,9 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
# Default: 1
|
# Default: 1
|
||||||
fetch-depth: ''
|
fetch-depth: ''
|
||||||
|
|
||||||
|
# Date like `2days` or `1970-01-01`. Fetch a history after the specified time.
|
||||||
|
shallow-since: ''
|
||||||
|
|
||||||
# Whether to fetch tags, even if fetch-depth > 0.
|
# Whether to fetch tags, even if fetch-depth > 0.
|
||||||
# Default: false
|
# Default: false
|
||||||
fetch-tags: ''
|
fetch-tags: ''
|
||||||
@ -190,7 +193,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
## Fetch only the root files
|
## Fetch only the root files
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
sparse-checkout: .
|
sparse-checkout: .
|
||||||
```
|
```
|
||||||
@ -198,7 +201,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
## Fetch only the root files and `.github` and `src` folder
|
## Fetch only the root files and `.github` and `src` folder
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
.github
|
.github
|
||||||
@ -208,7 +211,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
## Fetch only a single file
|
## Fetch only a single file
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
README.md
|
README.md
|
||||||
@ -218,7 +221,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
## Fetch all history for all tags and branches
|
## Fetch all history for all tags and branches
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
```
|
```
|
||||||
@ -226,7 +229,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
## Checkout a different branch
|
## Checkout a different branch
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
ref: my-branch
|
ref: my-branch
|
||||||
```
|
```
|
||||||
@ -234,7 +237,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
## Checkout HEAD^
|
## Checkout HEAD^
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
- run: git checkout HEAD^
|
- run: git checkout HEAD^
|
||||||
@ -244,12 +247,12 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: main
|
path: main
|
||||||
|
|
||||||
- name: Checkout tools repo
|
- name: Checkout tools repo
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: my-org/my-tools
|
repository: my-org/my-tools
|
||||||
path: my-tools
|
path: my-tools
|
||||||
@ -260,10 +263,10 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Checkout tools repo
|
- name: Checkout tools repo
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: my-org/my-tools
|
repository: my-org/my-tools
|
||||||
path: my-tools
|
path: my-tools
|
||||||
@ -274,12 +277,12 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: main
|
path: main
|
||||||
|
|
||||||
- name: Checkout private tools
|
- name: Checkout private tools
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: my-org/my-private-tools
|
repository: my-org/my-private-tools
|
||||||
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
|
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
|
||||||
@ -292,7 +295,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
## Checkout pull request HEAD commit instead of merge commit
|
## Checkout pull request HEAD commit instead of merge commit
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
```
|
```
|
||||||
@ -308,7 +311,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
```
|
```
|
||||||
|
|
||||||
## Push a commit using the built-in token
|
## Push a commit using the built-in token
|
||||||
@ -319,7 +322,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- run: |
|
- run: |
|
||||||
date > generated.txt
|
date > generated.txt
|
||||||
# Note: the following account information will not work on GHES
|
# Note: the following account information will not work on GHES
|
||||||
@ -341,7 +344,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
- run: |
|
- run: |
|
||||||
|
|||||||
@ -1157,6 +1157,7 @@ async function setup(testName: string): Promise<void> {
|
|||||||
sparseCheckout: [],
|
sparseCheckout: [],
|
||||||
sparseCheckoutConeMode: true,
|
sparseCheckoutConeMode: true,
|
||||||
fetchDepth: 1,
|
fetchDepth: 1,
|
||||||
|
shallowSince: '',
|
||||||
fetchTags: false,
|
fetchTags: false,
|
||||||
showProgress: true,
|
showProgress: true,
|
||||||
lfs: false,
|
lfs: false,
|
||||||
|
|||||||
@ -74,6 +74,8 @@ inputs:
|
|||||||
fetch-depth:
|
fetch-depth:
|
||||||
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
|
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
|
||||||
default: 1
|
default: 1
|
||||||
|
shallow-since:
|
||||||
|
description: 'Date like `2days` or `1970-01-01`. Fetch a history after the specified time.'
|
||||||
fetch-tags:
|
fetch-tags:
|
||||||
description: 'Whether to fetch tags, even if fetch-depth > 0.'
|
description: 'Whether to fetch tags, even if fetch-depth > 0.'
|
||||||
default: false
|
default: false
|
||||||
|
|||||||
@ -72,6 +72,8 @@ We want to take this opportunity to make behavioral changes, from v1. This docum
|
|||||||
fetch-depth:
|
fetch-depth:
|
||||||
description: 'Number of commits to fetch. 0 indicates all history for all tags and branches.'
|
description: 'Number of commits to fetch. 0 indicates all history for all tags and branches.'
|
||||||
default: 1
|
default: 1
|
||||||
|
shallow-since:
|
||||||
|
description: 'Date like `2days` or `1970-01-01`. Fetch a history after the specified time.'
|
||||||
lfs:
|
lfs:
|
||||||
description: 'Whether to download Git-LFS files'
|
description: 'Whether to download Git-LFS files'
|
||||||
default: false
|
default: false
|
||||||
@ -155,7 +157,7 @@ Fetch only the SHA being built and set depth=1. This significantly reduces the f
|
|||||||
|
|
||||||
If a SHA isn't available (e.g. multi repo), then fetch only the specified ref with depth=1.
|
If a SHA isn't available (e.g. multi repo), then fetch only the specified ref with depth=1.
|
||||||
|
|
||||||
The input `fetch-depth` can be used to control the depth.
|
The input `fetch-depth` and `shallow-since` can be used to control the depth.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
- Fetching a single commit is supported by Git wire protocol version 2. The git client uses protocol version 0 by default. The desired protocol version can be overridden in the git config or on the fetch command line invocation (`-c protocol.version=2`). We will override on the fetch command line, for transparency.
|
- Fetching a single commit is supported by Git wire protocol version 2. The git client uses protocol version 0 by default. The desired protocol version can be overridden in the git config or on the fetch command line invocation (`-c protocol.version=2`). We will override on the fetch command line, for transparency.
|
||||||
|
|||||||
14
dist/index.js
vendored
14
dist/index.js
vendored
@ -835,6 +835,9 @@ class GitCommandManager {
|
|||||||
if (options.filter) {
|
if (options.filter) {
|
||||||
args.push(`--filter=${options.filter}`);
|
args.push(`--filter=${options.filter}`);
|
||||||
}
|
}
|
||||||
|
if (options.shallowSince) {
|
||||||
|
args.push(`--shallow-since=${options.shallowSince}`);
|
||||||
|
}
|
||||||
if (options.fetchDepth && options.fetchDepth > 0) {
|
if (options.fetchDepth && options.fetchDepth > 0) {
|
||||||
args.push(`--depth=${options.fetchDepth}`);
|
args.push(`--depth=${options.fetchDepth}`);
|
||||||
}
|
}
|
||||||
@ -975,13 +978,16 @@ class GitCommandManager {
|
|||||||
yield this.execGit(args);
|
yield this.execGit(args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
submoduleUpdate(fetchDepth, recursive) {
|
submoduleUpdate(fetchDepth, recursive, shallowSince) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const args = ['-c', 'protocol.version=2'];
|
const args = ['-c', 'protocol.version=2'];
|
||||||
args.push('submodule', 'update', '--init', '--force');
|
args.push('submodule', 'update', '--init', '--force');
|
||||||
if (fetchDepth > 0) {
|
if (fetchDepth > 0) {
|
||||||
args.push(`--depth=${fetchDepth}`);
|
args.push(`--depth=${fetchDepth}`);
|
||||||
}
|
}
|
||||||
|
if (shallowSince) {
|
||||||
|
args.push(`--shallow-since=${shallowSince}`);
|
||||||
|
}
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
args.push('--recursive');
|
args.push('--recursive');
|
||||||
}
|
}
|
||||||
@ -2023,6 +2029,12 @@ function getInputs() {
|
|||||||
result.fetchDepth = 0;
|
result.fetchDepth = 0;
|
||||||
}
|
}
|
||||||
core.debug(`fetch depth = ${result.fetchDepth}`);
|
core.debug(`fetch depth = ${result.fetchDepth}`);
|
||||||
|
// Shallow since
|
||||||
|
if (core.getInput('fetch-depth') && core.getInput('shallow-since')) {
|
||||||
|
throw new Error('`fetch-depth` and `shallow-since` cannot be used at the same time');
|
||||||
|
}
|
||||||
|
result.shallowSince = core.getInput('shallow-since');
|
||||||
|
core.debug(`shallow since = ${result.shallowSince}`);
|
||||||
// Fetch tags
|
// Fetch tags
|
||||||
result.fetchTags =
|
result.fetchTags =
|
||||||
(core.getInput('fetch-tags') || 'false').toUpperCase() === 'TRUE';
|
(core.getInput('fetch-tags') || 'false').toUpperCase() === 'TRUE';
|
||||||
|
|||||||
@ -37,6 +37,7 @@ export interface IGitCommandManager {
|
|||||||
options: {
|
options: {
|
||||||
filter?: string
|
filter?: string
|
||||||
fetchDepth?: number
|
fetchDepth?: number
|
||||||
|
shallowSince?: string
|
||||||
fetchTags?: boolean
|
fetchTags?: boolean
|
||||||
showProgress?: boolean
|
showProgress?: boolean
|
||||||
}
|
}
|
||||||
@ -56,8 +57,12 @@ export interface IGitCommandManager {
|
|||||||
shaExists(sha: string): Promise<boolean>
|
shaExists(sha: string): Promise<boolean>
|
||||||
submoduleForeach(command: string, recursive: boolean): Promise<string>
|
submoduleForeach(command: string, recursive: boolean): Promise<string>
|
||||||
submoduleSync(recursive: boolean): Promise<void>
|
submoduleSync(recursive: boolean): Promise<void>
|
||||||
submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void>
|
|
||||||
submoduleStatus(): Promise<boolean>
|
submoduleStatus(): Promise<boolean>
|
||||||
|
submoduleUpdate(
|
||||||
|
fetchDepth: number,
|
||||||
|
recursive: boolean,
|
||||||
|
shallowSince?: string
|
||||||
|
): Promise<void>
|
||||||
tagExists(pattern: string): Promise<boolean>
|
tagExists(pattern: string): Promise<boolean>
|
||||||
tryClean(): Promise<boolean>
|
tryClean(): Promise<boolean>
|
||||||
tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
|
tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
|
||||||
@ -280,6 +285,7 @@ class GitCommandManager {
|
|||||||
options: {
|
options: {
|
||||||
filter?: string
|
filter?: string
|
||||||
fetchDepth?: number
|
fetchDepth?: number
|
||||||
|
shallowSince?: string
|
||||||
fetchTags?: boolean
|
fetchTags?: boolean
|
||||||
showProgress?: boolean
|
showProgress?: boolean
|
||||||
}
|
}
|
||||||
@ -298,6 +304,10 @@ class GitCommandManager {
|
|||||||
args.push(`--filter=${options.filter}`)
|
args.push(`--filter=${options.filter}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.shallowSince) {
|
||||||
|
args.push(`--shallow-since=${options.shallowSince}`)
|
||||||
|
}
|
||||||
|
|
||||||
if (options.fetchDepth && options.fetchDepth > 0) {
|
if (options.fetchDepth && options.fetchDepth > 0) {
|
||||||
args.push(`--depth=${options.fetchDepth}`)
|
args.push(`--depth=${options.fetchDepth}`)
|
||||||
} else if (
|
} else if (
|
||||||
@ -448,13 +458,21 @@ class GitCommandManager {
|
|||||||
await this.execGit(args)
|
await this.execGit(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
async submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> {
|
async submoduleUpdate(
|
||||||
|
fetchDepth: number,
|
||||||
|
recursive: boolean,
|
||||||
|
shallowSince?: string
|
||||||
|
): Promise<void> {
|
||||||
const args = ['-c', 'protocol.version=2']
|
const args = ['-c', 'protocol.version=2']
|
||||||
args.push('submodule', 'update', '--init', '--force')
|
args.push('submodule', 'update', '--init', '--force')
|
||||||
if (fetchDepth > 0) {
|
if (fetchDepth > 0) {
|
||||||
args.push(`--depth=${fetchDepth}`)
|
args.push(`--depth=${fetchDepth}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shallowSince) {
|
||||||
|
args.push(`--shallow-since=${shallowSince}`)
|
||||||
|
}
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
args.push('--recursive')
|
args.push('--recursive')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,12 @@ export interface IGitSourceSettings {
|
|||||||
fetchDepth: number
|
fetchDepth: number
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch tags, even if fetchDepth > 0 (default: false)
|
* Deepen or shorten the history of a shallow repository to include all reachable commits after
|
||||||
|
*/
|
||||||
|
shallowSince: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch tags, even if fetchDepth > 0 (default: false)
|
||||||
*/
|
*/
|
||||||
fetchTags: boolean
|
fetchTags: boolean
|
||||||
|
|
||||||
|
|||||||
@ -108,6 +108,15 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
}
|
}
|
||||||
core.debug(`fetch depth = ${result.fetchDepth}`)
|
core.debug(`fetch depth = ${result.fetchDepth}`)
|
||||||
|
|
||||||
|
// Shallow since
|
||||||
|
if (core.getInput('fetch-depth') && core.getInput('shallow-since')) {
|
||||||
|
throw new Error(
|
||||||
|
'`fetch-depth` and `shallow-since` cannot be used at the same time'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
result.shallowSince = core.getInput('shallow-since')
|
||||||
|
core.debug(`shallow since = ${result.shallowSince}`)
|
||||||
|
|
||||||
// Fetch tags
|
// Fetch tags
|
||||||
result.fetchTags =
|
result.fetchTags =
|
||||||
(core.getInput('fetch-tags') || 'false').toUpperCase() === 'TRUE'
|
(core.getInput('fetch-tags') || 'false').toUpperCase() === 'TRUE'
|
||||||
|
|||||||
@ -120,7 +120,7 @@ function updateUsage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateUsage(
|
updateUsage(
|
||||||
'actions/checkout@v5',
|
'actions/checkout@v6',
|
||||||
path.join(__dirname, '..', '..', 'action.yml'),
|
path.join(__dirname, '..', '..', 'action.yml'),
|
||||||
path.join(__dirname, '..', '..', 'README.md')
|
path.join(__dirname, '..', '..', 'README.md')
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user