Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(gradle-wrapper): autoReplace (#6004)
- Loading branch information
Showing
11 changed files
with
10 additions
and
700 deletions.
There are no files selected for viewing
396 changes: 0 additions & 396 deletions
396
lib/datasource/gradle-version/__snapshots__/index.spec.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
lib/manager/gradle-wrapper/__snapshots__/update.spec.ts.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,26 @@ | ||
import { coerce } from 'semver'; | ||
import { logger } from '../../logger'; | ||
import { PackageFile, PackageDependency } from '../common'; | ||
import * as semverVersioning from '../../versioning/semver'; | ||
import * as gradleVersioning from '../../versioning/gradle'; | ||
import * as datasourceGradleVersion from '../../datasource/gradle-version'; | ||
import { DISTRIBUTION_CHECKSUM_REGEX, DISTRIBUTION_URL_REGEX } from './search'; | ||
|
||
const DISTRIBUTION_URL_REGEX = /^(?<assignment>distributionUrl\s*=\s*)\S*-(?<version>(\d|\.)+)-(?<type>bin|all)\.zip\s*$/; | ||
|
||
export function extractPackageFile(fileContent: string): PackageFile | null { | ||
logger.debug('gradle-wrapper.extractPackageFile()'); | ||
const lines = fileContent.split('\n'); | ||
|
||
let lineNumber = 0; | ||
for (const line of lines) { | ||
const distributionUrlMatch = DISTRIBUTION_URL_REGEX.exec(line); | ||
if (distributionUrlMatch) { | ||
const dependency: PackageDependency = { | ||
datasource: datasourceGradleVersion.id, | ||
depType: 'gradle-wrapper', | ||
depName: 'gradle', | ||
currentValue: coerce(distributionUrlMatch.groups.version).toString(), | ||
managerData: { | ||
lineNumber, | ||
gradleWrapperType: distributionUrlMatch.groups.type, | ||
}, | ||
versioning: semverVersioning.id, | ||
currentValue: distributionUrlMatch.groups.version, | ||
datasource: datasourceGradleVersion.id, | ||
versioning: gradleVersioning.id, | ||
}; | ||
|
||
let shaLineNumber = 0; | ||
for (const shaLine of lines) { | ||
const shaMatch = DISTRIBUTION_CHECKSUM_REGEX.test(shaLine); | ||
if (shaMatch) { | ||
dependency.managerData.checksumLineNumber = shaLineNumber; | ||
break; | ||
} | ||
shaLineNumber += 1; | ||
} | ||
|
||
logger.debug(dependency, 'Gradle Wrapper'); | ||
return { deps: [dependency] }; | ||
} | ||
lineNumber += 1; | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters