Skip to content

Commit 85f36e3

Browse files
authored
Merge pull request #432 from codacy/feature/ignore-uncommitted-changes
Feature/ignore uncommitted changes
2 parents 6b0ec18 + 6c81722 commit 85f36e3

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ Found [Clone] 7 duplicated lines with 10 tokens:
203203
* `--format` [default: text] - Change the output format (e.g. json)
204204
* `--commit-uuid` [default: latest commit of current git branch] - Set the commit UUID that will receive the results on Codacy
205205
* `--skip-commit-uuid-validation` [default: false] - Force using a commit UUID even if it doesn't belong to the current git branch.
206+
* `--skip-uncommitted-files-check` [default: false] - Skip check for uncommitted files in the analysis directory
206207
* `--upload` [default: false] - Request to push results to Codacy
207208
* `--skip-ssl-verification` [default: false] - Skip the SSL certificate verification when communicating with the Codacy API
208209
* `--parallel` [default: 2] - Number of tools to run in parallel

cli/src/main/scala/com/codacy/analysis/cli/command/AnalyseCommand.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,24 @@ class AnalyseCommand(analyze: Analyze,
120120
},
121121
{ repository =>
122122
for {
123-
_ <- validateNoUncommitedChanges(repository, configuration.upload.upload)
123+
_ <- validateNoUncommitedChanges(
124+
repository,
125+
configuration.upload.upload,
126+
analyze.skipUncommittedFilesCheckValue)
124127
_ <- validateGitCommitUuid(repository, analyze.commitUuid, analyze.skipCommitUuidValidationValue)
125128
} yield ()
126129
})
127130
}
128131

129-
private def validateNoUncommitedChanges(repository: Repository, upload: Boolean): Either[CLIError, Unit] = {
132+
private def validateNoUncommitedChanges(repository: Repository,
133+
upload: Boolean,
134+
skipUncommittedFilesCheck: Boolean): Either[CLIError, Unit] = {
130135
repository.uncommitedFiles.fold(
131136
{ _ =>
132137
Right(())
133138
},
134139
{ uncommitedFiles =>
135-
if (uncommitedFiles.nonEmpty) {
140+
if (!skipUncommittedFilesCheck && uncommitedFiles.nonEmpty) {
136141
val error: CLIError = CLIError.UncommitedChanges(uncommitedFiles)
137142
if (upload) {
138143
logger.error(error.message)

cli/src/main/scala/com/codacy/analysis/cli/command/CLIApp.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ final case class Analyze(
144144
commitUuid: Option[Commit.Uuid] = Option.empty,
145145
@ExtraName("s") @ValueDescription("[default: false] - Force using a commit UUID")
146146
skipCommitUuidValidation: Int @@ Counter = Tag.of(0),
147+
@ExtraName("g") @ValueDescription("[default: false] - Skip the check for uncommitted files in the analysis directory")
148+
skipUncommittedFilesCheck: Int @@ Counter = Tag.of(0),
147149
@ExtraName("u") @ValueDescription("If the results should be uploaded to the API")
148150
upload: Int @@ Counter = Tag.of(0),
149151
@ExtraName("i") @ValueDescription(
@@ -178,6 +180,7 @@ final case class Analyze(
178180
val forceFilePermissionsValue: Boolean = forceFilePermissions.## > 0
179181
val ghCodeScanningCompatValue: Boolean = ghCodeScanningCompat.## > 0
180182
val skipCommitUuidValidationValue: Boolean = skipCommitUuidValidation.## > 0
183+
val skipUncommittedFilesCheckValue: Boolean = skipUncommittedFilesCheck.## > 0
181184
val skipSslVerificationValue: Boolean = skipSslVerification.## > 0
182185

183186
}

0 commit comments

Comments
 (0)