Changeset 282714 in webkit
- Timestamp:
- Sep 17, 2021, 5:22:35 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/setup.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py (modified) (4 diffs)
-
Scripts/libraries/webkitscmpy/webkitscmpy/program/pull.py (modified) (2 diffs)
-
Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r282711 r282714 1 2021-09-17 Jonathan Bedard <jbedard@apple.com> 2 3 [webkitscmpy] Refactor PR branch management 4 https://bugs.webkit.org/show_bug.cgi?id=230432 5 <rdar://problem/83258413> 6 7 Reviewed by Stephanie Lewis. 8 9 * Scripts/libraries/webkitscmpy/setup.py: Bump version. 10 * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto. 11 * Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py: 12 (Branch): Specify that the 'eng' prefix is for pull-requests. 13 (Branch.normalize_branch_name): Normalized branch names should consider other developement prefixes. 14 (Branch.editable): Check if a branch is editable. Only includes development branches at the moment, 15 will include commit-queue in the near future. 16 (Branch.branch_point): Moved from pull_request.py. 17 (Branch.main): 18 (Branch.normalize_issue): Renamed normalize_branch_name. 19 * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull.py: 20 (Pull.main): branch_point is now owned Branch command. 21 * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py: 22 (PullRequest.main): Match DEV_BRANCHES instead of PREFIX, branch_point is now owned Branch command. 23 (PullRequest.branch_point): Moved to branch.py. 24 1 25 2021-09-17 Kate Cheney <katherine_cheney@apple.com> 2 26 -
trunk/Tools/Scripts/libraries/webkitscmpy/setup.py
r282409 r282714 30 30 setup( 31 31 name='webkitscmpy', 32 version='2.2. 0',32 version='2.2.1', 33 33 description='Library designed to interact with git and svn repositories.', 34 34 long_description=readme(), -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py
r282409 r282714 47 47 ) 48 48 49 version = Version(2, 2, 0)49 version = Version(2, 2, 1) 50 50 51 51 AutoInstall.register(Package('fasteners', Version(0, 15, 0))) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py
r281363 r282714 26 26 from .command import Command 27 27 28 from webkitcorepy import run, Terminal28 from webkitcorepy import run, string_utils, Terminal 29 29 from webkitscmpy import local, log 30 30 … … 34 34 help = 'Create a local development branch from the current checkout state' 35 35 36 PR EFIX = 'eng'36 PR_PREFIX = 'eng' 37 37 38 38 @classmethod … … 45 45 46 46 @classmethod 47 def normalize_issue(cls, issue): 48 if not issue or issue.startswith(cls.PREFIX): 49 return issue 50 return '{}/{}'.format(cls.PREFIX, issue) 47 def normalize_branch_name(cls, name, repository=None): 48 if not name or (repository or local.Scm).DEV_BRANCHES.match(name): 49 return name 50 return '{}/{}'.format(cls.PR_PREFIX, name) 51 52 @classmethod 53 def editable(cls, branch, repository=None): 54 if (repository or local.Scm).DEV_BRANCHES.match(branch): 55 return True 56 return False 57 58 @classmethod 59 def branch_point(cls, repository): 60 cnt = 0 61 commit = None 62 while not commit or cls.editable(commit.branch, repository=repository): 63 cnt += 1 64 commit = repository.find(argument='HEAD~{}'.format(cnt), include_log=False, include_identifier=False) 65 if cnt > 1 or commit.branch != repository.branch: 66 log.warning(' Found {}...'.format(string_utils.pluralize(cnt, 'commit'))) 67 else: 68 log.warning(' No commits on editable branch') 69 70 return commit 51 71 52 72 @classmethod … … 58 78 if not args.issue: 59 79 args.issue = Terminal.input('Branch name: ') 60 args.issue = cls.normalize_ issue(args.issue)80 args.issue = cls.normalize_branch_name(args.issue) 61 81 62 82 if run([repository.executable(), 'check-ref-format', args.issue], capture_output=True).returncode: -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull.py
r281821 r282714 23 23 import sys 24 24 25 from .branch import Branch 25 26 from .command import Command 26 from .pull_request import PullRequest27 27 from webkitscmpy import local 28 28 … … 40 40 41 41 if isinstance(repository, local.Git): 42 branch_point = PullRequest.branch_point(args, repository, **kwargs)42 branch_point = Branch.branch_point(repository) 43 43 return repository.pull(rebase=True, branch=branch_point.branch) 44 44 return repository.pull() -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py
r282404 r282714 26 26 from .branch import Branch 27 27 28 from webkitcorepy import arguments, run , string_utils28 from webkitcorepy import arguments, run 29 29 from webkitscmpy import local, log, remote 30 30 … … 83 83 84 84 @classmethod 85 def branch_point(cls, args, repository, **kwargs):86 cnt = 087 commit = None88 while not commit or commit.branch.startswith(Branch.PREFIX):89 cnt += 190 commit = repository.find(argument='HEAD~{}'.format(cnt), include_log=False, include_identifier=False)91 log.warning(' Found {}...'.format(string_utils.pluralize(cnt, 'commit')))92 93 return commit94 95 @classmethod96 85 def main(cls, args, repository, **kwargs): 97 86 if not isinstance(repository, local.Git): … … 99 88 return 1 100 89 101 if not repository. branch.startswith(Branch.PREFIX):90 if not repository.DEV_BRANCHES.match(repository.branch): 102 91 if Branch.main(args, repository, **kwargs): 103 92 sys.stderr.write("Abandoning pushing pull-request because '{}' could not be created\n".format(args.issue)) … … 111 100 return result 112 101 113 branch_point = cls.branch_point(args, repository, **kwargs)102 branch_point = Branch.branch_point(repository) 114 103 if args.rebase or (args.rebase is None and repository.config().get('pull.rebase')): 115 104 log.warning("Rebasing '{}' on '{}'...".format(repository.branch, branch_point.branch))
Note:
See TracChangeset
for help on using the changeset viewer.