def update_current_branch(ref_name): commit = repo.head.commit commit_count = 1 while commit: if (commit.author.email == '*****@*****.**' and commit.message.strip() == 'Daily bump.'): break # We support merge commits but only with 2 parensts assert len(commit.parents) <= 2 commit = commit.parents[-1] commit_count += 1 print('%d revisions since last Daily bump' % commit_count) datestamp_path = os.path.join(args.git_path, 'gcc/DATESTAMP') if (read_timestamp(datestamp_path) != current_timestamp or args.dry_mode or args.current): head = repo.head.commit # if HEAD is a merge commit, start with second parent # (branched that is being merged into the current one) assert len(head.parents) <= 2 if len(head.parents) == 2: head = head.parents[1] commits = parse_git_revisions(args.git_path, '%s..%s' % (commit.hexsha, head.hexsha), ref_name) commits = [c for c in commits if c.info.hexsha not in IGNORED_COMMITS] for git_commit in reversed(commits): prepend_to_changelog_files(repo, args.git_path, git_commit, not args.dry_mode) if args.dry_mode: diff = repo.git.diff('HEAD') patch = os.path.join(args.dry_mode, branch.name.split('/')[-1] + '.patch') with open(patch, 'w+') as f: f.write(diff) print('branch diff written to %s' % patch) repo.git.checkout(force=True) else: # update timestamp print('DATESTAMP will be changed:') with open(datestamp_path, 'w+') as f: f.write(current_timestamp) repo.git.add(datestamp_path) if not args.current: repo.index.commit('Daily bump.') if args.push: repo.git.push('origin', branch) print('branch is pushed') else: print('DATESTAMP unchanged')
def update_current_branch(): commit = repo.head.commit commit_count = 1 while commit: if (commit.author.email == '*****@*****.**' and commit.message.strip() == 'Daily bump.'): break commit = commit.parents[0] commit_count += 1 print('%d revisions since last Daily bump' % commit_count) datestamp_path = os.path.join(args.git_path, 'gcc/DATESTAMP') if (read_timestamp(datestamp_path) != current_timestamp or args.dry_mode or args.current): commits = parse_git_revisions(args.git_path, '%s..HEAD' % commit.hexsha) for git_commit in reversed(commits): prepend_to_changelog_files(repo, args.git_path, git_commit, not args.dry_mode) if args.dry_mode: diff = repo.git.diff('HEAD') patch = os.path.join(args.dry_mode, branch.name.split('/')[-1] + '.patch') with open(patch, 'w+') as f: f.write(diff) print('branch diff written to %s' % patch) repo.git.checkout(force=True) else: # update timestamp print('DATESTAMP will be changed:') with open(datestamp_path, 'w+') as f: f.write(current_timestamp) repo.git.add(datestamp_path) if not args.current: repo.index.commit('Daily bump.') if args.push: repo.git.push('origin', branch) print('branch is pushed') else: print('DATESTAMP unchanged')
'if not specified: HEAD') parser.add_argument('-g', '--git-path', default='.', help='Path to git repository') parser.add_argument('-p', '--print-changelog', action='store_true', help='Print final changelog entires') parser.add_argument('-v', '--verbose', action='store_true', help='Print verbose information') args = parser.parse_args() retval = 0 for git_commit in parse_git_revisions(args.git_path, args.revisions): res = 'OK' if git_commit.success else 'FAILED' print('Checking %s: %s' % (git_commit.original_info.hexsha, res)) if git_commit.success: if args.print_changelog: git_commit.print_output() else: for error in git_commit.errors: print('ERR: %s' % error) if args.verbose and error.details: print(error.details) retval = 1 exit(retval)
print('branch pulled and checked out') assert not repo.index.diff(None) commit = branch.commit commit_count = 1 while commit: if (commit.author.email == '*****@*****.**' and commit.message.strip() == 'Daily bump.'): break commit = commit.parents[0] commit_count += 1 print('%d revisions since last Daily bump' % commit_count) datestamp_path = os.path.join(args.git_path, 'gcc/DATESTAMP') if (read_timestamp(datestamp_path) != current_timestamp or args.dry_mode): commits = parse_git_revisions(args.git_path, '%s..HEAD' % commit.hexsha) for git_commit in reversed(commits): prepend_to_changelog_files(repo, args.git_path, git_commit, not args.dry_mode) if args.dry_mode: diff = repo.git.diff('HEAD') patch = os.path.join(args.dry_mode, branch.name.split('/')[-1] + '.patch') with open(patch, 'w+') as f: f.write(diff) print('branch diff written to %s' % patch) repo.git.checkout(force=True) else: # update timestamp print('DATESTAMP will be changed:') with open(datestamp_path, 'w+') as f:
branch.checkout() print('=== Working on: %s ===' % branch) assert not repo.index.diff(None) commit = branch.commit commit_count = 1 while commit: if (commit.author.email == '*****@*****.**' and commit.message.strip() == 'Daily bump.'): break commit = commit.parents[0] commit_count += 1 print('%d revisions since last Daily bump' % commit_count) datestamp_path = os.path.join(args.git_path, 'gcc/DATESTAMP') if read_timestamp(datestamp_path) != current_timestamp: print('DATESTAMP will be changed:') # TODO: set strict=True after testing period commits = parse_git_revisions(args.git_path, '%s..HEAD' % commit.hexsha, strict=False) for git_commit in commits: prepend_to_changelog_files(repo, args.git_path, git_commit) # update timestamp with open(datestamp_path, 'w+') as f: f.write(current_timestamp) repo.git.add(datestamp_path) repo.index.commit('Daily bump.') # TODO: push the repository else: print('DATESTAMP unchanged')
from git_repository import parse_git_revisions parser = argparse.ArgumentParser(description='Check git ChangeLog format ' 'of a commit') parser.add_argument('revisions', default='HEAD', nargs='?', help='Git revisions (e.g. hash~5..hash or just hash)') parser.add_argument('-g', '--git-path', default='.', help='Path to git repository') parser.add_argument('-p', '--print-changelog', action='store_true', help='Print final changelog entires') parser.add_argument('-n', '--non-strict-mode', action='store_true', help='Use non-strict mode (allow changes in ChangeLog and ' 'other automatically updated files).') args = parser.parse_args() retval = 0 for git_commit in parse_git_revisions(args.git_path, args.revisions, not args.non_strict_mode): res = 'OK' if git_commit.success else 'FAILED' print('Checking %s: %s' % (git_commit.hexsha, res)) if git_commit.success: if args.print_changelog: git_commit.print_output() else: for error in git_commit.errors: print('ERR: %s' % error) retval = 1 exit(retval)