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

Allow to disable the shallow clone check (by default it will check if it's shallow clone) #1092

Merged
merged 2 commits into from
Mar 12, 2024
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: 9 additions & 4 deletions dist/azure/gitversion/execute/bundle.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dist/azure/gitversion/execute/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
"required": false,
"helpMarkDown": "Whether to disable GitVersion normalization"
},
{
"name": "disableShallowCloneCheck",
"type": "boolean",
"label": "Disable Shallow Clone Check",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to disable GitVersion shallow clone check"
},
{
"name": "useConfigFile",
"type": "boolean",
Expand Down
13 changes: 9 additions & 4 deletions dist/azure/gitversion/setup/bundle.js

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions dist/github/gitversion/execute/bundle.js

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions dist/github/gitversion/setup/bundle.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/examples/azure/gitversion/execute/usage-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ disableNormalization:
description: Whether to disable GitVersion normalization
required: false
default: 'false'
disableShallowCloneCheck:
description: Whether to disable the check for shallow clone
required: false
default: 'false'
useConfigFile:
description: Whether to use a custom configuration file
required: false
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/github/gitversion/execute/usage-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ disableNormalization:
description: Whether to disable GitVersion normalization
required: false
default: 'false'
disableShallowCloneCheck:
description: Whether to disable the check for shallow clone
required: false
default: 'false'
useConfigFile:
description: Whether to use a custom configuration file
required: false
Expand Down
4 changes: 4 additions & 0 deletions gitversion/execute/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
description: Whether to disable GitVersion normalization
required: false
default: 'false'
disableShallowCloneCheck:
description: Whether to disable the check for shallow clone
required: false
default: 'false'
useConfigFile:
description: Whether to use a custom configuration file
required: false
Expand Down
2 changes: 2 additions & 0 deletions src/tools/gitversion/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum ExecuteFields {
targetPath = 'targetPath',
disableCache = 'disableCache',
disableNormalization = 'disableNormalization',
disableShallowCloneCheck = 'disableShallowCloneCheck',
useConfigFile = 'useConfigFile',
configFilePath = 'configFilePath',
overrideConfig = 'overrideConfig',
Expand All @@ -17,6 +18,7 @@ export interface GitVersionSettings {
[ExecuteFields.targetPath]: string
[ExecuteFields.disableCache]: boolean
[ExecuteFields.disableNormalization]: boolean
[ExecuteFields.disableShallowCloneCheck]: boolean
[ExecuteFields.useConfigFile]: boolean
[ExecuteFields.configFilePath]: string
[ExecuteFields.overrideConfig]: string[]
Expand Down
2 changes: 2 additions & 0 deletions src/tools/gitversion/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class GitVersionSettingsProvider extends SettingsProvider implements IGit

const disableCache = this.buildAgent.getBooleanInput(ExecuteFields.disableCache)
const disableNormalization = this.buildAgent.getBooleanInput(ExecuteFields.disableNormalization)
const disableShallowCloneCheck = this.buildAgent.getBooleanInput(ExecuteFields.disableShallowCloneCheck)

const useConfigFile = this.buildAgent.getBooleanInput(ExecuteFields.useConfigFile)
const configFilePath = this.buildAgent.getInput(ExecuteFields.configFilePath)
Expand All @@ -31,6 +32,7 @@ export class GitVersionSettingsProvider extends SettingsProvider implements IGit
targetPath,
disableCache,
disableNormalization,
disableShallowCloneCheck,
useConfigFile,
configFilePath,
overrideConfig,
Expand Down
12 changes: 7 additions & 5 deletions src/tools/gitversion/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
public async run(options: GitVersionSettings): Promise<IExecResult> {
const workDir = this.getRepoDir(options)

const isShallowResult = await this.execute('git', ['-C', workDir, 'rev-parse', '--is-shallow-repository'])
if (isShallowResult.code === 0 && isShallowResult.stdout.trim() === 'true') {
throw new Error(
'The repository is shallow. Consider disabling shallow clones. See https://github.com/GitTools/actions/blob/main/docs/cloning.md for more information.'
)
if (!options.disableShallowCloneCheck) {
const isShallowResult = await this.execute('git', ['-C', workDir, 'rev-parse', '--is-shallow-repository'])
if (isShallowResult.code === 0 && isShallowResult.stdout.trim() === 'true') {
throw new Error(
'The repository is shallow. Consider disabling shallow clones. See https://github.com/GitTools/actions/blob/main/docs/cloning.md for more information.'
)
}
}

const args = this.getArguments(workDir, options)
Expand Down