def _get_repo_version_str(beta): """See above for description of this string.""" if beta is not None: date_str = datetime.date.today().strftime('%Y%m%d') return 'GOOG;noto-emoji:%s;BETA %s' % (date_str, beta) p = tool_utils.resolve_path('[emoji]') commit, date, _ = tool_utils.git_head_commit(p) if not tool_utils.git_check_remote_commit(p, commit): raise Exception('emoji not on upstream master branch') date_re = re.compile(r'(\d{4})-(\d{2})-(\d{2})') m = date_re.match(date) if not m: raise Exception('could not match "%s" with "%s"' % (date, date_re.pattern)) ymd = ''.join(m.groups()) return 'GOOG;noto-emoji:%s:%s' % (ymd, commit[:12])
def _get_fonts_repo_version_info(): prefix = tool_utils.resolve_path('[fonts]') commit, date, commit_msg = tool_utils.git_head_commit(prefix) # check that commit is on the upstream master if not tool_utils.git_check_remote_commit(prefix, commit): raise Exception( 'commit %s (%s) not on upstream master branch' % ( commit[:12], commit_msg.splitlines()[0].strip())) date_re = re.compile(r'(\d{4})-(\d{2})-(\d{2})') m = date_re.match(date) if not m: raise Exception('could not match "%s" with "%s"' % (date, date_re.pattern)) ymd = ''.join(m.groups()) return 'GOOG;noto-fonts:%s:%s' % (ymd, commit[:12])
def get_repo_info(skip_checks): """Looks at the three noto fonts repos (fonts, cjk, emoji) and gets information about the current state of each. Returns a mapping from 'fonts', 'cjk', and 'emoji' to the corresponding info. If skip_checks is not set, checks that the repos are in a good state (at a known annotated tag and there are no pending commits), otherwise an exception is raised.""" repo_info = {} errors = [] for repo_name in 'fonts cjk emoji'.split(): msg_lines = [] repo = tool_utils.resolve_path('[%s]' % repo_name) repo_head_commit = tool_utils.git_head_commit(repo) repo_branch = tool_utils.git_get_branch(repo) msg_lines.append('Repo: noto-%s' % repo_name) if skip_checks: msg_lines.append('Branch: %s' % repo_branch) msg_lines.append('Commit: %s\nSubject: %s' % repo_head_commit) else: if not tool_utils.git_is_clean(repo): errors.append('repo noto-%s is not clean' % repo_name) continue repo_tag = None for tag in tool_utils.git_tags(repo): if tag[0] == repo_head_commit[0]: # matching commits repo_tag = tag break if not repo_tag: errors.append('noto-%s is not at a release tag' % repo_name) continue tag_commit, tag_name, tag_date = tag tag_info = tool_utils.git_tag_info(repo, tag_name) msg_lines.append( 'Tag: %s\nDate: %s\nCommit:%s\n\n%s' % ( tag_name, tag_date, tag_commit, tag_info)) repo_info[repo_name] = '\n'.join(msg_lines) if errors: for _, v in sorted(repo_info.iteritems()): print v raise Exception('Some repos are not clean\n' + '\n'.join(errors)) return repo_info
def _get_fonts_repo_version_info(repo_tag): prefix = tool_utils.resolve_path(repo_tag) commit, date, commit_msg = tool_utils.git_head_commit(prefix) # check that commit is on the upstream master if not tool_utils.git_check_remote_commit(prefix, commit): raise Exception( 'commit %s (%s) not on upstream master branch' % ( commit[:12], commit_msg.splitlines()[0].strip())) date_re = re.compile(r'(\d{4})-(\d{2})-(\d{2})') m = date_re.match(date) if not m: raise Exception('could not match "%s" with "%s"' % (date, date_re.pattern)) ymd = ''.join(m.groups()) # hack tag to get the formal repo name. strip enclosing brackets... repo_name = 'noto-' + repo_tag[1:-1].replace('_', '-') return 'GOOG;%s:%s:%s' % (repo_name, ymd, commit[:12])