-
Notifications
You must be signed in to change notification settings - Fork 135
Format diff task #988
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
Format diff task #988
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
374fbda
Format diff task
CRogers 8d8a5ca
use new class name
iamdanfox 79d51dd
Add generated changelog entries
iamdanfox 9b07712
WIP test
iamdanfox 3cb742b
git add and git commit
iamdanfox 65026aa
Nice description
iamdanfox 6f89efc
-Drecreate=true
iamdanfox 4110d46
Move group and onlyIf
iamdanfox bf66fd2
Don't require the feature flag
iamdanfox 86f457c
Redundant modifier
iamdanfox da5fb85
Merge remote-tracking branch 'origin/develop' into format-diff
iamdanfox 3e68a7d
Use the upstream formatDiff task
iamdanfox 4fbd7ff
test passes
iamdanfox 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| type: improvement | ||
| improvement: | ||
| description: > | ||
| Run `./gradlew formatDiff` to reformat the relevant sections of any uncommitted changed Java files | ||
| (relies on `git diff -U0 HEAD` under the hood) | ||
| links: | ||
| - https://github.com/palantir/gradle-baseline/pull/988 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,11 @@ class BaselineFormatIntegrationTest extends AbstractPluginTest { | |
| id 'java' | ||
| id 'com.palantir.baseline-format' | ||
| } | ||
| repositories { | ||
| // to resolve the `palantirJavaFormat` configuration | ||
| maven { url 'https://dl.bintray.com/palantir/releases' } | ||
| jcenter() | ||
| } | ||
| '''.stripIndent() | ||
|
|
||
| def noJavaBuildFile = ''' | ||
|
|
@@ -227,4 +232,41 @@ class BaselineFormatIntegrationTest extends AbstractPluginTest { | |
| BuildResult result = with('spotlessJavaCheck').build() | ||
| result.task(":spotlessJava").outcome == TaskOutcome.SUCCESS | ||
| } | ||
|
|
||
| def 'formatDiff updates only lines changed in git diff'() { | ||
| when: | ||
| buildFile << standardBuildFile | ||
| "git init".execute(Collections.emptyList(), projectDir).waitFor() | ||
| "git config user.name Foo".execute(Collections.emptyList(), projectDir).waitFor() | ||
| "git config user.email [email protected]".execute(Collections.emptyList(), projectDir).waitFor() | ||
|
|
||
| file('src/main/java/Main.java') << ''' | ||
| class Main { | ||
| public static void crazyExistingFormatting ( String... args) { | ||
|
|
||
| } | ||
| } | ||
| '''.stripIndent() | ||
|
|
||
| "git add .".execute(Collections.emptyList(), projectDir).waitFor() | ||
| "git commit -m Commit".execute(Collections.emptyList(), projectDir).waitFor() | ||
|
|
||
| file('src/main/java/Main.java').text = ''' | ||
| class Main { | ||
| public static void crazyExistingFormatting ( String... args) { | ||
| System.out.println("Reformat me please"); | ||
| } | ||
| } | ||
| '''.stripIndent() | ||
|
|
||
| then: | ||
| with('formatDiff', '-Pcom.palantir.baseline-format.palantir-java-format').build() | ||
| file('src/main/java/Main.java').text == ''' | ||
| class Main { | ||
| public static void crazyExistingFormatting ( String... args) { | ||
| System.out.println("Reformat me please"); | ||
| } | ||
| } | ||
| '''.stripIndent() | ||
| } | ||
| } | ||
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.