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

Add shallow-since option #619

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix branch conditions
  • Loading branch information
satotake committed Oct 20, 2021
commit 9dceaac6c65adcbc8ffd2db31291b8eb06e8d39c
6 changes: 3 additions & 3 deletions src/git-command-manager.ts
Original file line number Diff line number Diff line change
@@ -187,10 +187,10 @@ class GitCommandManager {
}

args.push('--prune', '--progress', '--no-recurse-submodules')
if (fetchDepth && fetchDepth > 0) {
args.push(`--depth=${fetchDepth}`)
} else if (shallowSince) {
if (shallowSince) {
args.push(`--shallow-since=${shallowSince}`)
} else if (fetchDepth && fetchDepth > 0) {
args.push(`--depth=${fetchDepth}`)
} else if (
fshelper.fileExistsSync(
path.join(this.workingDirectory, '.git', 'shallow')
12 changes: 6 additions & 6 deletions src/input-helper.ts
Original file line number Diff line number Diff line change
@@ -81,6 +81,12 @@ export function getInputs(): IGitSourceSettings {
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'
core.debug(`clean = ${result.clean}`)

if (core.getInput('fetch-depth') && core.getInput('shallow-since')) {
throw new Error(
'`fetch-depth` and `shallow-since` cannot be used at the same time'
)
}

// Fetch depth
result.fetchDepth = Math.floor(Number(core.getInput('fetch-depth') || '1'))
if (isNaN(result.fetchDepth) || result.fetchDepth < 0) {
@@ -92,12 +98,6 @@ export function getInputs(): IGitSourceSettings {
result.shallowSince = core.getInput('shallow-since')
core.debug(`shallow since = ${result.shallowSince}`)

if (result.fetchDepth > 0 && result.shallowSince) {
throw new Error(
'`fetch-depath` and `shallow-since` cannot be used at the same time'
)
}

// LFS
result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE'
core.debug(`lfs = ${result.lfs}`)