Skip to content

Instantly share code, notes, and snippets.

@rodrigo-brito
Created April 15, 2020 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigo-brito/a9fa7985b39ec262efbe1f167ac4439c to your computer and use it in GitHub Desktop.
Save rodrigo-brito/a9fa7985b39ec262efbe1f167ac4439c to your computer and use it in GitHub Desktop.
package refdiff.examples;
import java.io.File;
import refdiff.core.RefDiff;
import refdiff.core.diff.CstDiff;
import refdiff.core.diff.Relationship;
import refdiff.parsers.go.GoPlugin;
public class RefDiffExampleGo {
public static void main(String[] args) throws Exception {
runExample();
}
private static void runExample() throws Exception {
// This is a temp folder to clone or checkout git repositories.
File tempFolder = new File("temp");
// Creates a RefDiff instance configured with the Go plugin.
try (GoPlugin goPlugin = new GoPlugin(tempFolder)) {
RefDiff refDiff = new RefDiff(goPlugin);
File repo = refDiff.cloneGitRepository(
new File(tempFolder, "go-refactoring-example.git"),
"https://github.com/rodrigo-brito/go-refactoring-example.git");
CstDiff diffForCommit = refDiff.computeDiffForCommit(repo, "e1f5a1f26bf66c33112316549000d9ae01eb84ed");
printRefactorings("Refactorings found in commit e1f5a1f26bf66c33112316549000d9ae01eb84ed", diffForCommit);
}
}
private static void printRefactorings(String headLine, CstDiff diff) {
System.out.println(headLine);
for (Relationship rel : diff.getRefactoringRelationships()) {
System.out.println(rel.getStandardDescription());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment