Title: Message Title
tzafrir updated an issue
Jenkins / JENKINS-40023
JGit changelog list no changes prior to merge commit
Change By:
tzafrir
git-client version 2.1.0 Adding Jgit changelog does not work well when setting max revisions limit, if the below test case in GitAPITestCase revisions containt merge commits . java fails with JGit but passes with CliGit. For JGit it seems that after That is because RevWalker check will only return the merge commit at HEAD number of revision as set by limitations , it finds no prior commits but ChangelogCommand default behaviour is to list and show skip merge commits. Resulting in returning less commits then requested by the changelog user . Whereas This can be seen by the CliGit does find below test case (for GitApiTestCase class) where JGit returns empty changelog if the head commit with the message "commit1" is a merge commit, and returns it's SHA1 max limit was set to 1. The test will pass if the max limit is increased to 2. {code}public void test_changelog_with_merge_commit test_changelog_with_merge_commit_and_max_log_history () throws Exception {w.init();w.commitEmpty("init");// First commit to branch1w.git.branch("branch1");w.git.checkout("branch1");w.touch("file1", "content1");w.git.add("file1");w.git.commit("commit1");String commitSha1 = w.git.revParse("HEAD").name();// Merge branch1 into masterw.git.checkout("master");String mergeMessage = "Merge message to be tested.";w.git.merge().setMessage(mergeMessage).setGitPluginFastForwardMode(MergeCommand.GitPluginFastForwardMode.NO_FF).setRevisionToMerge(w.git.getHeadRev(w.repoPath(), "branch1")).execute(); // Obtain last commit messageString mergeSha1 StringWriter writer = new StringWriter(); w.git. revParse changelog ( "HEAD" ). name max ( 1 ) .to(writer).execute() ; // Changing max limit to 2 will pass the test check_changelog_sha1 assertThat ( commitSha1 writer.toString() , "master" not(isEmptyString( ) )) ;} {code}
Add Comment