Search in sources :

Example 31 with GitPatchManagementServiceImpl

use of org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl in project fuse-karaf by jboss-fuse.

the class GitConflictResolutionIT method reportForXml.

@Test
public void reportForXml() throws Exception {
    prepareChanges3();
    RevWalk rw = new RevWalk(git.getRepository());
    git.checkout().setName("custom").setCreateBranch(false).call();
    ObjectId commit = git.getRepository().resolve("patched");
    CherryPickResult result = git.cherryPick().include(commit).call();
    RevCommit cMaster = rw.parseCommit(git.getRepository().resolve("master"));
    RevCommit cCustom = rw.parseCommit(git.getRepository().resolve("custom"));
    RevCommit cPatched = rw.parseCommit(git.getRepository().resolve("patched"));
    new GitPatchManagementServiceImpl().handleCherryPickConflict(null, git, result, git.getRepository().parseCommit(commit), true, PatchKind.NON_ROLLUP, "x", false, false);
    RevCommit cMerged = git.commit().setMessage("resolved").call();
    // we have 4 commits (7349224 is a custom change that's conflicting with "patched" branch):
    /*
           * 92a9ad8 - (HEAD -> custom) resolved
           * 7349224 - custom etc/org.ops4j.pax.logging.cfg
           | * 5777547 - (patched) patched etc/org.ops4j.pax.logging.cfg
           |/
           * 306f328 - (master) original etc/org.ops4j.pax.logging.cfg
         */
    FileWriter writer = new FileWriter("target/report2.html");
    PatchData pd = new PatchData("my-patch-id2");
    PatchResult patchResult = PatchResult.load(pd, getClass().getResourceAsStream("/conflicts/example1/fuse-karaf-7.0.0.fuse-000160.patch.result"));
    Set<String> conflicts = new HashSet<>();
    conflicts.add("etc/maven-settings.xml");
    DiffUtils.generateDiffReport(new Patch(pd, null), patchResult, git, conflicts, cMaster, cCustom, cPatched, cMerged, writer);
    writer.close();
}
Also used : CherryPickResult(org.eclipse.jgit.api.CherryPickResult) GitPatchManagementServiceImpl(org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl) PatchData(org.jboss.fuse.patch.management.PatchData) ObjectId(org.eclipse.jgit.lib.ObjectId) AbbreviatedObjectId(org.eclipse.jgit.lib.AbbreviatedObjectId) FileWriter(java.io.FileWriter) PatchResult(org.jboss.fuse.patch.management.PatchResult) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Patch(org.jboss.fuse.patch.management.Patch) RevCommit(org.eclipse.jgit.revwalk.RevCommit) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

GitPatchManagementServiceImpl (org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl)31 Test (org.junit.Test)25 GitPatchRepository (org.jboss.fuse.patch.management.impl.GitPatchRepository)22 File (java.io.File)18 Git (org.eclipse.jgit.api.Git)18 ObjectId (org.eclipse.jgit.lib.ObjectId)12 RevCommit (org.eclipse.jgit.revwalk.RevCommit)12 Map (java.util.Map)8 Ref (org.eclipse.jgit.lib.Ref)6 RevWalk (org.eclipse.jgit.revwalk.RevWalk)6 IOException (java.io.IOException)5 Patch (org.jboss.fuse.patch.management.Patch)5 BundleStartLevel (org.osgi.framework.startlevel.BundleStartLevel)5 FileReader (java.io.FileReader)4 LinkedList (java.util.LinkedList)4 Properties (java.util.Properties)4 FeaturesProcessing (org.apache.karaf.features.internal.model.processing.FeaturesProcessing)4 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)4 PatchData (org.jboss.fuse.patch.management.PatchData)4 PatchManagement (org.jboss.fuse.patch.management.PatchManagement)4