Ori.livneh has submitted this change and it was merged.
Change subject: ~ori: add `branchdir` script
......................................................................
~ori: add `branchdir` script
Change-Id: Ie9211ecab017dd1a79f7efb52f5b7d3cbbba29a8
---
A modules/admin/files/home/ori/.binned/branchdir
M modules/admin/files/home/ori/.hosts/tin
2 files changed, 35 insertions(+), 4 deletions(-)
Approvals:
Ori.livneh: Verified; Looks good to me, approved
diff --git a/modules/admin/files/home/ori/.binned/branchdir
b/modules/admin/files/home/ori/.binned/branchdir
new file mode 100755
index 0000000..a178f8d
--- /dev/null
+++ b/modules/admin/files/home/ori/.binned/branchdir
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+from __future__ import print_function
+
+import os
+import re
+import sys
+
+if not (len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1].isdigit())):
+ print('Usage: %s BRANCH_NUMBER' % __file__, file=sys.stderr)
+ sys.exit(1)
+
+search_dir = ('/srv/mediawiki-staging'
+ if os.path.exists('/srv/mediawiki-staging')
+ else '/srv/mediawiki')
+target_branch = '(\d+)' if len(sys.argv) == 1 else sys.argv[1]
+branch_pattern = r'php-(\d+)\.(\d+)\.(\d+)-wmf\.' + target_branch + '$'
+branch_version = []
+branch_dirname = None
+
+for node in os.listdir(search_dir):
+ match = re.match(branch_pattern, node)
+ if match:
+ version = map(int, match.groups())
+ if version > branch_version:
+ branch_dirname = node
+ branch_version = version
+
+if branch_dirname:
+ print(branch_dirname)
+ sys.exit(0)
+else:
+ sys.exit(1)
diff --git a/modules/admin/files/home/ori/.hosts/tin
b/modules/admin/files/home/ori/.hosts/tin
index 2617af1..5d3ffe7 100755
--- a/modules/admin/files/home/ori/.hosts/tin
+++ b/modules/admin/files/home/ori/.hosts/tin
@@ -49,7 +49,7 @@
git fetch origin 2>&1 >/dev/null
git --no-pager diff HEAD origin
else
- branch_dir="$(find . -maxdepth 1 -type d -iregex
"./php-1.${1}.*-wmf.*" | sort | tail -1)"
+ branch_dir="$(branchdir $1)"
branch="origin/wmf/${branch_dir#./php-}"
cd "${branch_dir}"
git fetch 2>&1 >/dev/null
@@ -58,9 +58,7 @@
}
cdbranch() {
- cd "$MEDIAWIKI_STAGING_DIR"
- branch_dir="$(find . -maxdepth 1 -type d -iregex "./php-1.${1}.*-wmf.*" |
sort | tail -1)"
- cd "${branch_dir}"
+ cd "$(branchdir $1)"
}
bump() {
--
To view, visit https://gerrit.wikimedia.org/r/247766
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie9211ecab017dd1a79f7efb52f5b7d3cbbba29a8
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits