Changeset 287115 in webkit
- Timestamp:
- Dec 15, 2021, 4:51:44 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r287105 r287115 1 2021-12-15 Jonathan Bedard <jbedard@apple.com> 2 3 [reporelaypy] Forward branches to alternate remote 4 https://bugs.webkit.org/show_bug.cgi?id=234347 5 <rdar://problem/86526293> 6 7 Reviewed by Dewei Zhu. 8 9 * Scripts/libraries/reporelaypy/reporelaypy/__init__.py: Bump version. 10 * Scripts/libraries/reporelaypy/reporelaypy/checkout.py: 11 (Checkout.Encoder.default): Add remotes. 12 (Checkout.clone): After cloning a repository, add required remotes. 13 (Checkout.add_remotes): Track remotes in repository. 14 (Checkout.__init__): Allow caller to specify set of remotes to be tracked. 15 (Checkout.push_update): Push update for specified remote. 16 (Checkout.update_for): Return 'True' and 'False.' 17 (Checkout.update_all): If a branch is being updated, we should forward that 18 update to any tracked remotes. 19 * Scripts/libraries/reporelaypy/reporelaypy/hooks.py: 20 (HookProcessor.process_worker_hook): After updating a branch, forward that 21 update to any tracked remotes. 22 * Scripts/libraries/reporelaypy/reporelaypy/tests/checkout_unittest.py: 23 (CheckoutUnittest.test_constructor_no_sentinal): Capture debug logging. 24 * Scripts/libraries/reporelaypy/reporelaypy/tests/checkoutroute_unittest.py: 25 (CheckoutRouteUnittest.test_landing): Capture debug logging. 26 (CheckoutRouteUnittest.test_invoked_redirect): Ditto. 27 (CheckoutRouteUnittest.test_trac): Ditto. 28 * Scripts/libraries/reporelaypy/reporelaypy/tests/hooks_unittest.py: 29 (HooksUnittest.test_process): Test for any error logging. 30 (HooksUnittest.test_process_branch): Ditto. 31 * Scripts/libraries/reporelaypy/run: Allow caller to specify remote to be tracked. 32 * Scripts/libraries/reporelaypy/setup.py: Bump version. 33 1 34 2021-12-15 Don Olmstead <don.olmstead@sony.com> 2 35 -
trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py
r287054 r287115 45 45 ) 46 46 47 version = Version(0, 3, 1)47 version = Version(0, 4, 0) 48 48 49 49 import webkitflaskpy -
trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py
r287054 r287115 48 48 url=obj.url, 49 49 sentinal=obj.sentinal, 50 remotes=obj.remotes, 50 51 ) 51 52 if obj.fallback_repository: … … 61 62 62 63 @staticmethod 63 def clone(url, path, sentinal_file=None):64 def clone(url, path, remotes, sentinal_file=None): 64 65 run([local.Git.executable(), 'clone', url, path], cwd=os.path.dirname(path)) 65 66 run([local.Git.executable(), 'config', 'pull.ff', 'only'], cwd=path) 67 68 Checkout.add_remotes(local.Git(path), remotes) 66 69 67 70 if sentinal_file: … … 70 73 return 0 71 74 72 def __init__(self, path, url=None, http_proxy=None, sentinal=True, fallback_url=None, primary=True): 75 @staticmethod 76 def add_remotes(repository, remotes): 77 for name, url in (remotes or {}).items(): 78 run([repository.executable(), 'remote', 'add', name, url], cwd=repository.root_path) 79 80 def __init__(self, path, url=None, http_proxy=None, sentinal=True, fallback_url=None, primary=True, remotes=None): 73 81 self.sentinal = sentinal 74 82 self.path = path 75 83 self.url = url 84 self.remotes = remotes or dict() 76 85 self._repository = None 77 86 self._child_process = None … … 100 109 self.url, self.repository.url(name='origin'), 101 110 )) 111 if primary: 112 Checkout.add_remotes(self.repository, remotes) 102 113 return 103 114 except FileNotFoundError: … … 118 129 self._child_process = multiprocessing.Process( 119 130 target=self.clone, 120 args=(self.url, path, self. sentinal_file),131 args=(self.url, path, self.remotes, self.sentinal_file), 121 132 ) 122 133 self._child_process.start() 123 134 else: 124 self.clone(self.url, path )135 self.clone(self.url, path, self.remotes) 125 136 126 137 @property … … 165 176 return False 166 177 178 def push_update(self, branch=None, remote=None, track=False): 179 if not remote or remote in ('origin', 'fork'): 180 return False 181 182 branch = branch or self.repository.default_branch 183 if not track and self.is_updated(branch, remote=remote): 184 return False 185 186 return not run( 187 [self.repository.executable(), 'push', remote, branch, '-f'], 188 cwd=self.repository.root_path, 189 ).returncode 190 167 191 def update_for(self, branch=None, remote='origin', track=False): 168 192 if not self.repository: 169 193 sys.stderr.write("Cannot update '{}', clone still pending...\n".format(branch)) 170 return None194 return False 171 195 172 196 branch = branch or self.repository.default_branch … … 178 202 return False 179 203 elif track and branch not in self.repository.branches_for(remote=remote): 204 run([self.repository.executable(), 'fetch'], cwd=self.repository.root_path) 180 205 run( 181 206 [self.repository.executable(), 'branch', '--track', branch, 'remotes/{}/{}'.format(remote, branch)], … … 207 232 all_branches.remove(branch) 208 233 self.update_for(branch=branch, remote=remote) 234 [self.push_update(branch=branch, remote=remote) for remote in self.remotes.keys()] 209 235 210 236 # Then, track all untracked branches … … 214 240 cwd=self.repository.root_path, 215 241 ) 242 [self.push_update(branch=branch, remote=remote) for remote in self.remotes.keys()] 216 243 self.repository.cache.populate(branch=branch) -
trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py
r287045 r287115 24 24 import hmac 25 25 import json 26 import sys 26 27 27 28 from flask import current_app, json as fjson, request … … 67 68 branch = branch[len('refs/heads/'):] 68 69 self.checkout.update_for(branch, track=True) 70 [self.checkout.push_update(branch=branch, remote=remote, track=True) for remote in self.checkout.remotes.keys()] 69 71 except BaseException as e: 70 72 sys.stderr.write('{}\n'.format(e)) -
trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/checkout_unittest.py
r286576 r287115 43 43 44 44 def test_constructor_no_sentinal(self): 45 with mocks.local.Git(self.path) as repo :45 with mocks.local.Git(self.path) as repo, OutputCapture(): 46 46 Checkout(path=self.path, url=repo.remote, sentinal=False) 47 47 -
trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/checkoutroute_unittest.py
r286576 r287115 108 108 @mock_app 109 109 def test_landing(self, app=None, client=None): 110 with mocks.local.Git(self.path) as repo :110 with mocks.local.Git(self.path) as repo, OutputCapture(): 111 111 app.register_blueprint(CheckoutRoute( 112 112 Checkout(path=self.path, url=repo.remote, sentinal=False), … … 148 148 @mock_app 149 149 def test_invoked_redirect(self, app=None, client=None): 150 with mocks.local.Git(self.path, git_svn=True) as repo :150 with mocks.local.Git(self.path, git_svn=True) as repo, OutputCapture(): 151 151 app.register_blueprint(CheckoutRoute( 152 152 Checkout(path=self.path, url=repo.remote, sentinal=False), … … 163 163 @mock_app 164 164 def test_trac(self, app=None, client=None): 165 with mocks.local.Git(self.path, git_svn=True) as repo :165 with mocks.local.Git(self.path, git_svn=True) as repo, OutputCapture(): 166 166 app.register_blueprint(CheckoutRoute( 167 167 Checkout(path=self.path, url=repo.remote, sentinal=False), -
trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/hooks_unittest.py
r287045 r287115 72 72 @mock_app 73 73 def test_process(self, app=None, client=None): 74 with OutputCapture() , mocks.local.Git(self.path) as repo:74 with OutputCapture() as captured, mocks.local.Git(self.path) as repo: 75 75 database = Database() 76 76 app.register_blueprint(HookReceiver(database=database, debug=True)) … … 89 89 self.assertEqual(response.json(), []) 90 90 91 self.assertEqual(captured.stderr.getvalue(), '') 92 91 93 @mock_app 92 94 def test_process_branch(self, app=None, client=None): 93 with OutputCapture() , mocks.local.Git(self.path) as repo:95 with OutputCapture() as captured, mocks.local.Git(self.path) as repo: 94 96 database = Database() 95 97 app.register_blueprint(HookReceiver(database=database, debug=True)) … … 107 109 self.assertEqual(response.status_code, 200) 108 110 self.assertEqual(response.json(), []) 111 112 self.assertEqual(captured.stderr.getvalue(), '') 109 113 110 114 @mock_app -
trunk/Tools/Scripts/libraries/reporelaypy/run
r287045 r287115 73 73 help='Fallback repository URL', 74 74 ) 75 group.add_argument( 76 '--remote', dest='remotes', action='append', 77 help="Add an additional remote to forward changes to, formatted as 'name:url'", 78 ) 75 79 76 80 group = parser.add_argument_group('Database') … … 125 129 print('Connected to database!') 126 130 131 remotes = {} 132 for pair in args.remotes: 133 name, remote = pair.split(':', 1) 134 if not remote: 135 sys.stderr("Invalid forwarding remote '{}'".format(pair)) 136 return 1 137 remotes[name] = remote 138 127 139 print('Finding checkout...') 128 140 checkout = Checkout( … … 132 144 sentinal=args.sentinal, 133 145 fallback_url=args.fallback, 146 remotes=remotes, 134 147 ) 135 148 print('Git checkout:') … … 144 157 print(' Polling checkout with interval of {} seconds, doing first poll now...'.format(args.update_interval)) 145 158 checkout.update_all() 159 if remotes: 160 print('Forwarding updates to:') 161 for name, url in remotes.items(): 162 print(' {}: {}'.format(name, url)) 146 163 147 164 if args.redirector: -
trunk/Tools/Scripts/libraries/reporelaypy/setup.py
r287054 r287115 31 31 setup( 32 32 name='reporelaypy', 33 version='0. 3.1',33 version='0.4.0', 34 34 description='Library for visualizing, processing and storing test results.', 35 35 long_description=readme(),
Note:
See TracChangeset
for help on using the changeset viewer.