|
15 | 15 | */ |
16 | 16 | package com.palantir.gradle.gitversion |
17 | 17 |
|
| 18 | +import java.nio.file.Files |
| 19 | + |
18 | 20 | import org.eclipse.jgit.api.Git |
19 | 21 | import org.gradle.testkit.runner.BuildResult |
20 | 22 | import org.gradle.testkit.runner.GradleRunner |
@@ -151,6 +153,36 @@ class GitVersionPluginTests extends Specification { |
151 | 153 | buildResult.output.contains(':printVersion\n1.0.0.dirty\n') |
152 | 154 | } |
153 | 155 |
|
| 156 | + def 'git describe and clean when symlink is present' () { |
| 157 | + |
| 158 | + given: |
| 159 | + buildFile << ''' |
| 160 | + plugins { |
| 161 | + id 'com.palantir.git-version' |
| 162 | + } |
| 163 | + version gitVersion() |
| 164 | + '''.stripIndent() |
| 165 | + gitIgnoreFile << 'build' |
| 166 | + File fileToLinkTo = temporaryFolder.newFile('fileToLinkTo') |
| 167 | + fileToLinkTo << 'content' |
| 168 | + Files.createSymbolicLink(temporaryFolder.getRoot().toPath().resolve('fileLink'), fileToLinkTo.toPath()); |
| 169 | + |
| 170 | + File folderToLinkTo = temporaryFolder.newFolder('folderToLinkTo') |
| 171 | + new File(folderToLinkTo, 'dummyFile') << 'content' |
| 172 | + Files.createSymbolicLink(temporaryFolder.getRoot().toPath().resolve('folderLink'), folderToLinkTo.toPath()); |
| 173 | + |
| 174 | + Git git = Git.init().setDirectory(projectDir).call(); |
| 175 | + git.add().addFilepattern('.').call() |
| 176 | + git.commit().setMessage('initial commit').call() |
| 177 | + git.tag().setAnnotated(true).setMessage('1.0.0').setName('1.0.0').call() |
| 178 | + |
| 179 | + when: |
| 180 | + BuildResult buildResult = with('printVersion').build() |
| 181 | + |
| 182 | + then: |
| 183 | + buildResult.output.contains(':printVersion\n1.0.0\n') |
| 184 | + } |
| 185 | + |
154 | 186 | private GradleRunner with(String... tasks) { |
155 | 187 | GradleRunner.create() |
156 | 188 | .withPluginClasspath(pluginClasspath) |
|
0 commit comments