Add git.getBranchesContainsRef method
Add method to check which branches contains specific
commit sha.
Related-Prod: PRODX-3456
Change-Id: Ib7190b89ca6d9ac14b4db6e5417d7f9330b9d586
diff --git a/src/com/mirantis/mk/Git.groovy b/src/com/mirantis/mk/Git.groovy
index 667e43c..eb08e7d 100644
--- a/src/com/mirantis/mk/Git.groovy
+++ b/src/com/mirantis/mk/Git.groovy
@@ -621,16 +621,16 @@
}
/**
- * Return array with branches that contains specific tag
+ * Return array with branches that contains specific commit ref
*
* @param path Path to the git repository
- * @param tag search tag
+ * @param ref search ref
*/
-def getBranchesContainsTag(String path, String tag) {
+def getBranchesContainsRef(String path, String ref) {
List result = []
dir(path) {
def gitResult = sh (
- script: "git branch --all --contains tags/${tag}",
+ script: "git branch --all --contains ${ref}",
returnStdout: true
)
for (line in gitResult.split('\n')) {
@@ -641,3 +641,13 @@
}
return result
}
+
+/**
+ * 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) {
+ return getBranchesContainsRef(path, "tags/${tag}")
+}