Skip to content

Commit

Permalink
Merge pull request #1092 from arturcic/main
Browse files Browse the repository at this point in the history
Allow to disable the shallow clone check (by default it will check if it's shallow clone)
  • Loading branch information
arturcic authored Mar 12, 2024
2 parents 33df830 + 827776a commit a282519
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 21 deletions.
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

0 comments on commit a282519

Please sign in to comment.