-
Notifications
You must be signed in to change notification settings - Fork 3
add an option to create annotated tags #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4d54ac7
add option to create annotated Git tags
rzabini 3ea793f
add option to create annotated Git tags
rzabini f8cb8ec
add option to create annotated Git tags with message template
rzabini 58aec76
- add {{changes}} placeholder for annotated teg message
rzabini 17f8576
Shrink the diff.
nedtwigg 7806d6f
Merge branch 'diffplug:main' into main
rzabini 880591e
Fix imports and unclosed warnings in test.
nedtwigg e9a2266
The commitMessage is based on the next computed version, so the tag m…
nedtwigg 583a3c0
Fix mutability bug in Changelog.releaseUnreleased()
nedtwigg bb6e37e
Fix tests and minimize diff.
nedtwigg 7e8b497
Reduce codesize a bit.
nedtwigg fb41367
Update docs and readme.
nedtwigg 7f962ee
Fix another bug in Changelog.releaseUnreleased()
nedtwigg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
120 changes: 120 additions & 0 deletions
120
...-gradle/src/test/java/com/diffplug/spotless/changelog/gradle/ChangelogPluginPushTest.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| /* | ||
| * Copyright (C) 2019-2021 DiffPlug | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.diffplug.spotless.changelog.gradle; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Paths; | ||
| import org.eclipse.jgit.api.Git; | ||
| import org.eclipse.jgit.api.errors.GitAPIException; | ||
| import org.eclipse.jgit.revwalk.RevWalk; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
| import org.junit.rules.TestWatcher; | ||
| import org.junit.runner.Description; | ||
|
|
||
| public class ChangelogPluginPushTest extends GradleHarness { | ||
|
|
||
| @Rule | ||
| public DeleteOnSuccessTemporaryFolder temporaryFolder = new DeleteOnSuccessTemporaryFolder(new File("build")); | ||
| @Rule | ||
| public KeepTempFolderOnFailure keepTempFolderOnFailure = new KeepTempFolderOnFailure(temporaryFolder); | ||
|
|
||
| @Test | ||
| public void verifyAnnotatedTagMessage() throws IOException, GitAPIException { | ||
|
|
||
| final String testCaseFolder = "1.0.3-annotatedTag"; | ||
| File origin = initUpstreamRepo(testCaseFolder); | ||
|
|
||
| final File working = temporaryFolder.newFolder("working"); | ||
| Git git = Git.cloneRepository().setURI(origin.getAbsolutePath()) | ||
| .setDirectory(working).call(); | ||
|
|
||
| copyResourceFile(working, testCaseFolder, "CHANGELOG.md"); | ||
|
|
||
| gradleRunner().withProjectDir(working)/*.withDebug(true)*/ | ||
| .withArguments("changelogPush").build(); | ||
|
|
||
| assertEquals("Version is 1.0.3, here are the changes:" | ||
| + "\n\n### Fixed\n" | ||
| + "- this should be in tag message\n", | ||
| annotatedTagMessage(git, "release/1.0.3")); | ||
| } | ||
|
|
||
| private String annotatedTagMessage(Git localGit, final String tagName) throws IOException { | ||
| try (RevWalk walk = new RevWalk(localGit.getRepository())) { | ||
| return walk.parseTag( | ||
| localGit.getRepository().findRef(tagName).getObjectId()) | ||
| .getFullMessage(); | ||
| } | ||
| } | ||
|
|
||
| private File initUpstreamRepo(String testCaseFolder) throws IOException, GitAPIException { | ||
| File origin = temporaryFolder.newFolder("origin"); | ||
| Git git = Git.init().setDirectory(origin).call(); | ||
| copyResourceFile(origin, "settings.gradle"); | ||
| copyResourceFile(origin, testCaseFolder, "build.gradle"); | ||
| git.add().addFilepattern(".").call(); | ||
| git.commit() | ||
| .setMessage("Commit all changes including additions") | ||
| .call(); | ||
| return origin; | ||
| } | ||
|
|
||
| private void copyResourceFile(File working, String testCaseFolder, String fileName) throws IOException { | ||
| Files.copy(Paths.get("src/test/resources", testCaseFolder, fileName), working.toPath().resolve(fileName)); | ||
| } | ||
|
|
||
| private void copyResourceFile(File working, String fileName) throws IOException { | ||
| Files.copy(Paths.get("src/test/resources", fileName), working.toPath().resolve(fileName)); | ||
| } | ||
|
|
||
| static class KeepTempFolderOnFailure extends TestWatcher { | ||
| private final DeleteOnSuccessTemporaryFolder folder; | ||
|
|
||
| KeepTempFolderOnFailure(DeleteOnSuccessTemporaryFolder folder) { | ||
| this.folder = folder; | ||
| } | ||
|
|
||
| @Override | ||
| protected void failed(Throwable e, Description description) { | ||
| folder.disableDeletion(); | ||
| } | ||
| } | ||
|
|
||
| static class DeleteOnSuccessTemporaryFolder extends TemporaryFolder { | ||
|
|
||
| boolean canDelete = true; | ||
|
|
||
| public DeleteOnSuccessTemporaryFolder(File file) { | ||
| super(file); | ||
| } | ||
|
|
||
| @Override | ||
| protected void after() { | ||
| if (canDelete) | ||
| super.after(); | ||
| } | ||
|
|
||
| public void disableDeletion() { | ||
| canDelete = false; | ||
| } | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
...less-changelog-plugin-gradle/src/test/resources/1.0.3-annotatedTag/CHANGELOG.md
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Changelog | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Fixed | ||
| - this should be in tag message | ||
|
|
||
| ## [1.0.2] - 2021-04-23 | ||
|
|
||
| Initial release. |
8 changes: 8 additions & 0 deletions
8
spotless-changelog-plugin-gradle/src/test/resources/1.0.3-annotatedTag/build.gradle
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| plugins { | ||
| id 'com.diffplug.spotless-changelog' | ||
| } | ||
|
|
||
| spotlessChangelog { | ||
| branch 'master' | ||
| tagMessage 'Version is {{version}}, here are the changes:{{changes}}' | ||
| } |
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.