-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck-module-changes.gradle
34 lines (28 loc) · 1.21 KB
/
check-module-changes.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
apply from: "${project(":utils").projectDir}/get-git-root-dir.gradle"
ext.ensureNoChanges = { libVersion, moduleName, libVersionGradlePath ->
def logStream = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--pretty=%H', '--', "$libVersionGradlePath"
standardOutput = logStream
}
def bumpVersionCommit = logStream.toString().trim()
println "$moduleName bumpVersionCommit: $bumpVersionCommit"
def gitRootDir = getGitRootDir()
println "gitRootDir: $gitRootDir"
def diffStream = new ByteArrayOutputStream()
exec {
commandLine 'git', 'diff', '--name-only', bumpVersionCommit
standardOutput = diffStream
}
def diff = diffStream.toString().trim()
def diffPaths = diff
.split("\n")
.collect { file("$gitRootDir/$it").absolutePath }
.findAll { it.startsWith(project(":$moduleName").projectDir.absolutePath) }
def diffCount = diffPaths.size()
println "$moduleName diffCount: $diffCount"
if (diffCount > 0) {
throw new GradleException("Changes in $moduleName found since bumping version to $libVersion (commit: $bumpVersionCommit):\n" +
diffPaths.join("\n"))
}
}