#
# Some important environment variables:
#
-# - PTL_TOOL_BASE_REMOTE (the name for your upstream remote, default "upstream")
-# - PTL_TOOL_BASE_PATH (where your upstream -- i.e. https://github.com/ceph/ceph/ -- branch refs are, default "refs/remotes/upstream/")
# - PTL_TOOL_GITHUB_USER (your github username)
# - PTL_TOOL_GITHUB_API_KEY (your github api key, or what is stored in ~/.github.key)
# - PTL_TOOL_REDMINE_USER (your redmine username)
# - PTL_TOOL_USER (your desired username embedded in test branch names)
#
#
-# Because developers often have custom names for the ceph upstream remote
-# (https://github.com/ceph/ceph.git), You will probably want to export the
-# PTL_TOOL_BASE_PATH environment variable in your shell rc files before using
-# this script:
-#
-# export PTL_TOOL_BASE_PATH=refs/remotes/<remotename>/
-#
-# and PTL_TOOL_BASE_REMOTE as the name of your Ceph upstream remote (default: "upstream"):
-#
-# export PTL_TOOL_BASE_REMOTE=<remotename>
-#
-#
# You can use this tool to create a QA tracker ticket for you:
#
# $ python3 ptl-tool.py ... --create-qa --qa-release reef
BASE_PROJECT = os.getenv("PTL_TOOL_BASE_PROJECT", "ceph")
BASE_REPO = os.getenv("PTL_TOOL_BASE_REPO", "ceph")
-BASE_REMOTE = os.getenv("PTL_TOOL_BASE_REMOTE", "upstream")
-BASE_PATH = os.getenv("PTL_TOOL_BASE_PATH", "refs/remotes/upstream/")
+BASE_REMOTE_URL = os.getenv("PTL_TOOL_BASE_REMOTE_URL", f"https://github.com/{BASE_PROJECT}/{BASE_REPO}.git")
+CI_REPO = os.getenv("PTL_TOOL_CI_REPO", "ceph-ci")
+CI_REMOTE_URL = os.getenv("PTL_TOOL_CI_REMOTE_URL", f"git@github.com:{BASE_PROJECT}/{CI_REPO}.git")
GITDIR = os.getenv("PTL_TOOL_GITDIR", ".")
GITHUB_USER = os.getenv("PTL_TOOL_GITHUB_USER", os.getenv("PTL_TOOL_USER", getuser()))
GITHUB_API_KEY = None
R = Redmine(REDMINE_ENDPOINT, username=REDMINE_USER, key=REDMINE_API_KEY)
log.debug("connected")
- # First get the latest base branch and PRs from BASE_REMOTE
- remote = getattr(G.remotes, BASE_REMOTE)
- remote.fetch()
-
prs = args.prs
if args.pr_label is not None:
if args.pr_label == '' or args.pr_label.isspace():
else:
log.info("Detaching HEAD onto base: {}".format(base))
try:
- base_path = args.base_path + base
- base = next(ref for ref in G.refs if ref.path == base_path)
+ G.git.fetch(BASE_REMOTE_URL, base)
# So we know that we're not on an old test branch, detach HEAD onto ref:
- base.checkout()
- except StopIteration:
+ c = G.commit('FETCH_HEAD')
+ except git.exc.GitCommandError:
+ log.debug("could not fetch %s from %s", base, BASE_REMOTE_URL)
log.info(f"Trying to checkout uninterpreted base {base}")
c = G.commit(base)
- G.git.checkout(c)
+ G.git.checkout(c)
assert G.head.is_detached
qa_tracker_description = []
log.info("Merging PR #{pr}".format(pr=pr))
remote_ref = "refs/pull/{pr}/head".format(pr=pr)
- fi = remote.fetch(remote_ref)
- if len(fi) != 1:
- log.error("PR {pr} does not exist?".format(pr=pr))
+ try:
+ G.git.fetch(BASE_REMOTE_URL, remote_ref)
+ except git.exc.GitCommandError:
+ log.error("could not fetch %s from %s", remote_ref, BASE_REMOTE_URL)
sys.exit(1)
- tip = fi[0].ref.commit
+ tip = G.commit("FETCH_HEAD")
endpoint = f"https://api.github.com/repos/{BASE_PROJECT}/{BASE_REPO}/pulls/{pr}"
response = next(get(session, endpoint, paging=False))
if old_head != new_head:
rev = f'{old_head}..{new_head}'
for commit in G.iter_commits(rev=rev):
- qa_tracker_description.append(f'* "commit {commit}":https://github.com/ceph/ceph-ci/commit/{commit} -- {commit.summary}')
+ qa_tracker_description.append(f'* "commit {commit}":{CI_REMOTE_URL}/commit/{commit} -- {commit.summary}')
# If the branch is 'HEAD', leave HEAD detached (but use "main" for commit message)
if branch == 'HEAD':
custom_fields.append({'id': REDMINE_CUSTOM_FIELD_ID_QA_RUNS, 'value': branch})
custom_fields.append({'id': REDMINE_CUSTOM_FIELD_ID_QA_RELEASE, 'value': args.qa_release})
- G.remotes.ci.push(tag)
- origin_url = f'ceph/ceph-ci/commits/{tag.name}'
+ G.git.push(CI_REMOTE_URL, tag.name)
+ origin_url = f'{BASE_PROJECT}/{CI_REPO}/commits/{tag.name}'
custom_fields.append({'id': REDMINE_CUSTOM_FIELD_ID_GIT_BRANCH, 'value': origin_url})
issue_kwargs = {
parser.add_argument('--debug-build', dest='debug_build', action='store_true', help='append -debug to branch name prompting ceph-build to build with CMAKE_BUILD_TYPE=Debug')
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=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')