Changeset 277220 in webkit
- Timestamp:
- May 7, 2021, 6:08:08 PM (5 years ago)
- Location:
- trunk/Websites/perf.webkit.org
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
tools/sync-commits.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Websites/perf.webkit.org/ChangeLog
r275993 r277220 1 2021-05-07 Zhifei Fang <zhifei_fang@apple.com> 2 3 Add support for syncing repo with commit revision label. 4 https://bugs.webkit.org/show_bug.cgi?id=221982 5 6 Reviewed by Ryosuke Niwa. 7 8 Add new syncing option reportRevisionIdentifier, which will let the script try to sync the commit revision identifier from the commit message. 9 Add new syncing option reportSVNRevision, which will let the script try to report SVN revision from a git-svn repo. 10 11 * tools/sync-commits.py: 12 (main): 13 (load_repository): 14 (GitRepository.__init__): 15 (GitRepository.fetch_next_commit): 16 (GitRepository._git_hash_to_svn_revision): 17 (GitRepository._svn_revision_to_git_hash): 18 (GitRepository._revision_from_tokens): 19 (GitRepository._fetch_all_hashes): 20 1 21 2021-04-14 Zhifei Fang <zhifei_fang@apple.com> 2 22 -
trunk/Websites/perf.webkit.org/tools/sync-commits.py
r274800 r277220 17 17 from util import text_content 18 18 19 # There are some buggy commit messages: 20 # Canonical link: https://commits.webkit.org/https://commits.webkit.org/232477@main 21 REVISION_IDENTIFIER_RE = re.compile(r'Canonical link: (https\://commits\.webkit\.org/)+(?P<revision_identifier>\d+@[\w\.\-]+)\n') 19 22 20 23 def main(argv): … … 44 47 def load_repository(repository): 45 48 if 'gitCheckout' in repository: 46 return GitRepository(name=repository['name'], git_url=repository['url'], git_checkout=repository['gitCheckout'], git_branch=repository.get('branch')) 49 return GitRepository( 50 name=repository['name'], git_url=repository['url'], git_checkout=repository['gitCheckout'], 51 git_branch=repository.get('branch'), report_revision_identifier_in_commit_msg=repository.get('reportRevisionIdentifier'), 52 report_svn_revison=repository.get('reportSVNRevision')) 47 53 return SVNRepository(name=repository['name'], svn_url=repository['url'], should_trust_certificate=repository.get('trustCertificate', False), 48 54 use_server_auth=repository.get('useServerAuth', False), account_name_script_path=repository.get('accountNameFinderScript')) … … 193 199 class GitRepository(Repository): 194 200 195 def __init__(self, name, git_checkout, git_url, git_branch=None ):201 def __init__(self, name, git_checkout, git_url, git_branch=None, report_revision_identifier_in_commit_msg=False, report_svn_revison=False): 196 202 assert(os.path.isdir(git_checkout)) 197 203 super(GitRepository, self).__init__(name) … … 200 206 self._git_branch = git_branch 201 207 self._tokenized_hashes = [] 208 self._report_revision_identifier_in_commit_msg = report_revision_identifier_in_commit_msg 209 self._report_svn_revision = report_svn_revison 202 210 203 211 def fetch_next_commit(self, server_config, last_fetched): … … 206 214 tokens = self._tokenized_hashes[0] 207 215 else: 216 if self._report_svn_revision: 217 last_fetched_git_hash = self._git_hash_from_svn_revision(last_fetched) 218 if not last_fetched_git_hash: 219 self._fetch_remote() 220 last_fetched_git_hash = self._git_hash_from_svn_revision(last_fetched) 221 if not last_fetched_git_hash: 222 raise ValueError('Cannot find the git hash for the last fetched svn revision') 223 last_fetched = last_fetched_git_hash 208 224 tokens = self._find_next_hash(last_fetched) 209 225 if not tokens: … … 221 237 return None 222 238 239 def _svn_revision_from_git_hash(self, git_hash): 240 return self._run_git_command(['svn', 'find-rev', git_hash]).strip() 241 242 def _git_hash_from_svn_revision(self, revision): 243 return self._run_git_command(['svn', 'find-rev', 'r{}'.format(revision)]).strip() 244 223 245 def _revision_from_tokens(self, tokens): 224 246 current_hash = tokens[0] … … 230 252 message = self._run_git_command(['log', current_hash, '-1', '--pretty=%B']) 231 253 254 revision_identifier = None 255 if self._report_revision_identifier_in_commit_msg: 256 revision_identifier_match = REVISION_IDENTIFIER_RE.search(message) 257 if not revision_identifier_match: 258 raise ValueError('Expected commit message to include revision identifier, but cannot find it, will need a history rewrite to fix it') 259 revision_identifier = revision_identifier_match.group('revision_identifier') 260 261 current_revision = current_hash 262 previous_revision = previous_hash 263 if self._report_svn_revision: 264 current_revision = self._svn_revision_from_git_hash(current_hash) 265 if not current_revision: 266 raise ValueError('Cannot find SVN revison for {}'.format(current_hash)) 267 if previous_hash: 268 previous_revision = self._svn_revision_from_git_hash(previous_hash) 269 if not previous_revision: 270 raise ValueError('Cannot find SVN revison for {}'.format(previous_hash)) 271 232 272 return { 233 273 'repository': self._name, 234 'revision': current_hash, 235 'previousCommit': previous_hash, 274 'revision': current_revision, 275 'revisionIdentifier': revision_identifier, 276 'previousCommit': previous_revision, 236 277 'time': datetime.fromtimestamp(commit_time).strftime(r'%Y-%m-%dT%H:%M:%S.%f'), 237 278 'author': {'account': author_email, 'name': author_name}, … … 245 286 return None 246 287 288 def _fetch_remote(self): 289 self._run_git_command(['pull', self._git_url]) 290 if self._report_svn_revision: 291 self._run_git_command(['svn', 'fetch']) 292 247 293 def _fetch_all_hashes(self): 248 self._ run_git_command(['pull', self._git_url])294 self._fetch_remote() 249 295 scope = self._git_branch or '--all' 250 296 lines = self._run_git_command(['log', scope, '--date-order', '--reverse', '--pretty=%H %ct %ce %P']).split('\n')
Note:
See TracChangeset
for help on using the changeset viewer.