[Git] Add getGitCommitMessage() function
Related-To: PRODX-4768
Change-Id: I36534f21e81c705f5069ba7240ec4096d6042ba9
diff --git a/src/com/mirantis/mk/Git.groovy b/src/com/mirantis/mk/Git.groovy
index 94eb55b..f699b3e 100644
--- a/src/com/mirantis/mk/Git.groovy
+++ b/src/com/mirantis/mk/Git.groovy
@@ -80,6 +80,19 @@
}
/**
+ * Get commit message for given commit reference
+ */
+def getGitCommitMessage(String path, String commitRef = 'HEAD') {
+ dir(path) {
+ commitMsg = sh (
+ script: "git log --format=%B -n 1 ${commitRef}",
+ returnStdout: true
+ ).trim()
+ }
+ return commitMsg
+}
+
+/**
* Create new working branch for repo
*
* @param path Path to the git repository