-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
214 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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,69 @@ | ||
package com.github.maracas; | ||
|
||
import com.github.maracas.brokenuse.BrokenUse; | ||
import com.github.maracas.brokenuse.DeltaImpact; | ||
import com.github.maracas.delta.BreakingChange; | ||
import com.github.maracas.delta.Delta; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@SuppressWarnings("unused") | ||
class Usage { | ||
public static void main(String[] args) { | ||
LibraryJar v1 = LibraryJar.withSources( | ||
Path.of("test-data/comp-changes/old/target/comp-changes-old-0.0.1.jar"), | ||
SourcesDirectory.of(Path.of("test-data/comp-changes/old/"))); | ||
LibraryJar v2 = LibraryJar.withoutSources(Path.of("test-data/comp-changes/new/target/comp-changes-new-0.0.1.jar")); | ||
SourcesDirectory client = SourcesDirectory.of(Path.of("test-data/comp-changes/client/")); | ||
|
||
AnalysisQuery query = AnalysisQuery.builder() | ||
.oldVersion(v1) | ||
.newVersion(v2) | ||
.client(client) | ||
.build(); | ||
|
||
AnalysisResult result = new Maracas().analyze(query); | ||
System.out.println("Changes: " + result.delta()); | ||
System.out.println("Impact: " + result.allBrokenUses()); | ||
} | ||
|
||
void readmeUsage1() { | ||
Maracas maracas = new Maracas(); | ||
|
||
// Setting up the library versions and clients | ||
LibraryJar v1 = LibraryJar.withSources(Path.of("v1.jar"), Path.of("v1-sources/")); | ||
LibraryJar v2 = LibraryJar.withoutSources(Path.of("v2.jar")); | ||
SourcesDirectory client = SourcesDirectory.of(Path.of("/path/to/client")); | ||
|
||
// Option 1: using the query/result API | ||
AnalysisQuery query = AnalysisQuery.builder() | ||
.oldVersion(v1) | ||
.newVersion(v2) | ||
.client(client) | ||
.build(); | ||
|
||
AnalysisResult result = maracas.analyze(query); | ||
Delta delta = result.delta(); | ||
List<BreakingChange> breakingChanges = delta.getBreakingChanges(); | ||
Set<BrokenUse> brokenUses = result.allBrokenUses(); | ||
} | ||
|
||
void readmeUsage2() { | ||
Maracas maracas = new Maracas(); | ||
|
||
// Setting up the library versions and clients | ||
LibraryJar v1 = LibraryJar.withSources(Path.of("v1.jar"), Path.of("v1-sources/")); | ||
LibraryJar v2 = LibraryJar.withoutSources(Path.of("v2.jar")); | ||
SourcesDirectory client = SourcesDirectory.of(Path.of("/path/to/client")); | ||
|
||
// Option 2: invoking the analyses directly | ||
Delta delta = maracas.computeDelta(v1, v2); | ||
Collection<BreakingChange> breakingChanges = delta.getBreakingChanges(); | ||
|
||
DeltaImpact deltaImpact = maracas.computeDeltaImpact(client, delta); | ||
Set<BrokenUse> brokenUses = deltaImpact.brokenUses(); | ||
} | ||
} |
This file contains 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 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 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 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,53 @@ | ||
package com.github.maracas.forges; | ||
|
||
import com.github.maracas.AnalysisResult; | ||
import com.github.maracas.MaracasOptions; | ||
import com.github.maracas.brokenuse.BrokenUse; | ||
import com.github.maracas.delta.BreakingChange; | ||
import com.github.maracas.forges.analysis.CommitAnalyzer; | ||
import com.github.maracas.forges.analysis.PullRequestAnalysisResult; | ||
import com.github.maracas.forges.analysis.PullRequestAnalyzer; | ||
import com.github.maracas.forges.build.CommitBuilder; | ||
import com.github.maracas.forges.github.GitHubForge; | ||
import org.kohsuke.github.GitHubBuilder; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@SuppressWarnings("unused") | ||
class Usage { | ||
void readmeUsage1() throws IOException { | ||
// See https://github-api.kohsuke.org/ to setup the GitHubBuilder | ||
GitHubForge forge = new GitHubForge(GitHubBuilder.fromEnvironment().build()); | ||
|
||
// Option 1: analyzing a pull request | ||
PullRequestAnalyzer analyzer = new PullRequestAnalyzer(Path.of("/tmp"), forge); | ||
PullRequest pr = forge.fetchPullRequest("owner", "library", 42); | ||
|
||
PullRequestAnalysisResult result = analyzer.analyze(pr, MaracasOptions.newDefault()); | ||
List<BreakingChange> breakingChanges = result.breakingChanges(); | ||
Set<BrokenUse> brokenUses = result.brokenUses(); | ||
} | ||
|
||
void readmeUsage2() throws IOException { | ||
// See https://github-api.kohsuke.org/ to setup the GitHubBuilder | ||
GitHubForge forge = new GitHubForge(GitHubBuilder.fromEnvironment().build()); | ||
|
||
// Option 2: analyzing two arbitrary commits | ||
CommitAnalyzer analyzer = new CommitAnalyzer(); | ||
Commit v1 = forge.fetchCommit("owner", "library", "sha-v1"); | ||
Commit v2 = forge.fetchCommit("owner", "library", "sha-v2"); | ||
Commit client = forge.fetchCommit("owner", "client", "sha"); | ||
CommitBuilder builderV1 = new CommitBuilder(v1, Path.of("clone-v1/")); | ||
CommitBuilder builderV2 = new CommitBuilder(v2, Path.of("clone-v2/")); | ||
CommitBuilder builderClient = new CommitBuilder(client, Path.of("clone-client/")); | ||
|
||
AnalysisResult result = analyzer.analyzeCommits(builderV1, builderV2, | ||
List.of(builderClient), MaracasOptions.newDefault()); | ||
|
||
List<BreakingChange> breakingChanges = result.delta().getBreakingChanges(); | ||
Set<BrokenUse> brokenUses = result.allBrokenUses(); | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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
Oops, something went wrong.