summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2019-02-16 20:05:35 +0100
committerSage Weil <sage@redhat.com>2019-02-16 20:05:35 +0100
commit7840e7d8ba518ee42fa0ec6e0c10b2c176c96c77 (patch)
treeedd83f1609091caaa92c32a722b9205b82d7a388 /src/script
parentMerge pull request #26416 from dzafman/wip-fix-test-loops (diff)
downloadceph-7840e7d8ba518ee42fa0ec6e0c10b2c176c96c77.tar.xz
ceph-7840e7d8ba518ee42fa0ec6e0c10b2c176c96c77.zip
script/ptl-tool: allow invocation within a subdirectory
Make ptl-tool.py work from a subdirectory inside the repo (e.g., build/). Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src/script')
-rwxr-xr-xsrc/script/ptl-tool.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/script/ptl-tool.py b/src/script/ptl-tool.py
index 39f1141f875..6d37467477b 100755
--- a/src/script/ptl-tool.py
+++ b/src/script/ptl-tool.py
@@ -139,9 +139,18 @@ INDICATIONS = [
re.compile("(Tested-by: .+ <[\w@.-]+>)", re.IGNORECASE),
]
+# find containing git dir
+git_dir = GITDIR
+max_levels = 6
+while not os.path.exists(git_dir + '/.git'):
+ git_dir += '/..'
+ max_levels -= 1
+ if max_levels < 0:
+ break
+
CONTRIBUTORS = {}
NEW_CONTRIBUTORS = {}
-with codecs.open(".githubmap", encoding='utf-8') as f:
+with codecs.open(git_dir + "/.githubmap", encoding='utf-8') as f:
comment = re.compile("\s*#")
patt = re.compile("([\w-]+)\s+(.*)")
for line in f:
@@ -300,7 +309,7 @@ def build_branch(args):
if new_new_contributors:
# Check out the PR, add a commit adding to .githubmap
log.info("adding new contributors to githubmap in merge commit")
- with open(".githubmap", "a") as f:
+ with open(git_dir + "/.githubmap", "a") as f:
for c in new_new_contributors:
f.write("%s %s\n" % (c, new_new_contributors[c]))
G.index.add([".githubmap"])
@@ -348,7 +357,7 @@ def main():
parser.add_argument('--merge-branch-name', dest='merge_branch_name', action='store', default=False, help='name of the branch for merge messages')
parser.add_argument('--base', dest='base', action='store', default=default_base, help='base for branch')
parser.add_argument('--base-path', dest='base_path', action='store', default=BASE_PATH, help='base for branch')
- parser.add_argument('--git-dir', dest='git', action='store', default=GITDIR, help='git directory')
+ parser.add_argument('--git-dir', dest='git', action='store', default=git_dir, help='git directory')
parser.add_argument('--label', dest='label', action='store', default=default_label, help='label PRs for testing')
parser.add_argument('--pr-label', dest='pr_label', action='store', help='label PRs for testing')
parser.add_argument('prs', metavar="PR", type=int, nargs='*', help='Pull Requests to merge')