Skip to content

Commit 5f46273

Browse files
committed
Merge pull request #20 from palantir/test-symlinks
Add test coverage for symlink behavior
2 parents bd931e0 + 3ccd7b6 commit 5f46273

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/groovy/com/palantir/gradle/gitversion/GitVersionPluginTests.groovy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.palantir.gradle.gitversion
1717

18+
import java.nio.file.Files
19+
1820
import org.eclipse.jgit.api.Git
1921
import org.gradle.testkit.runner.BuildResult
2022
import org.gradle.testkit.runner.GradleRunner
@@ -151,6 +153,36 @@ class GitVersionPluginTests extends Specification {
151153
buildResult.output.contains(':printVersion\n1.0.0.dirty\n')
152154
}
153155

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+
154186
private GradleRunner with(String... tasks) {
155187
GradleRunner.create()
156188
.withPluginClasspath(pluginClasspath)

0 commit comments

Comments
 (0)