[Git] Add getBranchesContainsTag method
This method allow to get branch list which contains selected tag
Related-Prod: PRODX-3456
Change-Id: I3f22d5a0eb1142df4f87b00550d9b4a2fe363de4
diff --git a/src/com/mirantis/mk/Git.groovy b/src/com/mirantis/mk/Git.groovy
index a5203f5..e7af77b 100644
--- a/src/com/mirantis/mk/Git.groovy
+++ b/src/com/mirantis/mk/Git.groovy
@@ -619,3 +619,22 @@
}
return jsonChange
}
+
+/**
+ * Return array with branches that contains specific tag
+ *
+ * @param path Path to the git repository
+ * @param tag search tag
+ */
+def getBranchesContainsTag(String path, String tag) {
+ List result
+ dir(path) {
+ def gitResult = sh (
+ script: "git branch --contains tags/${tag}",
+ returnStdout: true
+ ).trim()
+ result = gitResult.readLines()
+ result.removeAll {it -> it.contains("HEAD detached")}
+ }
+ return result*.trim()
+}