Added log statements after commiting
This commit is contained in:
@@ -135,6 +135,7 @@ class GitRepo {
|
||||
try(Git git = this.gitFactory.open(file(project))) {
|
||||
git.add().addFilepattern(".").call();
|
||||
git.commit().setAllowEmpty(false).setMessage(message).call();
|
||||
printLog(git);
|
||||
} catch (EmtpyCommitException e) {
|
||||
log.info("There were no changes detected. Will not commit an empty commit");
|
||||
} catch (Exception e) {
|
||||
@@ -142,6 +143,16 @@ class GitRepo {
|
||||
}
|
||||
}
|
||||
|
||||
private void printLog(Git git) throws GitAPIException, IOException {
|
||||
int maxCount = 5;
|
||||
String currentBranch = git.getRepository().getBranch();
|
||||
log.info("Printing [{}] last commits for branch [{}]", maxCount, currentBranch);
|
||||
Iterable<RevCommit> commits = git.log().setMaxCount(maxCount).call();
|
||||
for (RevCommit commit : commits) {
|
||||
log.info("Name [{}], msg [{}]", commit.getId().name(), commit.getShortMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a tag with a given name
|
||||
* @param project
|
||||
@@ -210,6 +221,7 @@ class GitRepo {
|
||||
log.debug("The commit to be reverted is [{}]", commit);
|
||||
git.revert().include(commit).call();
|
||||
git.commit().setAmend(true).setMessage(message).call();
|
||||
printLog(git);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user