Skip to content

Instantly share code, notes, and snippets.

@jrodbx
Created March 8, 2019 03:58
Show Gist options
  • Save jrodbx/dcc81cb213e4c300c0e1ddfde4ae553d to your computer and use it in GitHub Desktop.
Save jrodbx/dcc81cb213e4c300c0e1ddfde4ae553d to your computer and use it in GitHub Desktop.
Hack to enable better Java to Kotlin diffs
#!/usr/bin/env bash
# Find all added *.kt files from last commit and mv to *.java
for f in $(git diff --name-status --diff-filter='A' HEAD~ "*.kt" | cut -f 2);
do mv -- "$f" "${f%.kt}.java";
done
# Commit the kt to java changes
git add .
git commit -m"kt to java"
# Revert, but stash before committing
git revert --no-commit HEAD
git stash
# Squash the java change into the original commit
git reset --soft HEAD~
git commit --amend --no-edit
# Pop the stashed revert changes and commit
git stash pop
git commit -am"java to kt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment