From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id DF100386F442; Thu, 11 Jun 2020 20:08:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF100386F442 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591906083; bh=RkwIs9gFkWLVvP4sK7/l4zBXDh+19o0Xju5qBas9v+A=; h=From:To:Subject:Date:From; b=ReCvCFZVoHJwhkY28ORGw0Y06ZoeSoAAEI7Xd4VJd+HjKWLcyk59Qc7Hrgrp8Km32 4ycxgZzehZDzPBjW1vFOvsEWujNMhfk1b52SCNloreNXQLef4Y2r8Wnnd3BdgL4Nqj qTwgV0Sf4e7/s9hp/9QRewvBUHrPfv3asL9qf2sc= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/c++-coroutines] git_update_version: add --current argument. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/heads/devel/c++-coroutines X-Git-Oldrev: 6a07010b774cb5a0b1790b857e69d3d8534eebd2 X-Git-Newrev: be11812eef33786f77676327667bf3885c1f33e8 Message-Id: <20200611200803.DF100386F442@sourceware.org> Date: Thu, 11 Jun 2020 20:08:03 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jun 2020 20:08:04 -0000 https://gcc.gnu.org/g:be11812eef33786f77676327667bf3885c1f33e8 commit be11812eef33786f77676327667bf3885c1f33e8 Author: Martin Liska Date: Thu Jun 11 13:34:53 2020 +0200 git_update_version: add --current argument. The argument can be useful to update arbitrary branch, the changes are added to git index and user is supposed to make a commit. contrib/ChangeLog: * gcc-changelog/git_update_version.py: Add --curent argument. Diff: --- contrib/gcc-changelog/git_update_version.py | 106 ++++++++++++++++------------ 1 file changed, 59 insertions(+), 47 deletions(-) diff --git a/contrib/gcc-changelog/git_update_version.py b/contrib/gcc-changelog/git_update_version.py index 6b6ccf68a5e..733a1a0f14a 100755 --- a/contrib/gcc-changelog/git_update_version.py +++ b/contrib/gcc-changelog/git_update_version.py @@ -66,60 +66,72 @@ parser.add_argument('-d', '--dry-mode', help='Generate patch for ChangeLog entries and do it' ' even if DATESTAMP is unchanged; folder argument' ' is expected') +parser.add_argument('-c', '--current', action='store_true', + help='Modify current branch (--push argument is ignored)') args = parser.parse_args() repo = Repo(args.git_path) origin = repo.remotes['origin'] -for ref in origin.refs: - assert ref.name.startswith('origin/') - name = ref.name[len('origin/'):] - if name in active_refs: - if name in repo.branches: - branch = repo.branches[name] + +def update_current_branch(): + commit = repo.head.commit + commit_count = 1 + while commit: + if (commit.author.email == 'gccadmin@gcc.gnu.org' + 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: - branch = repo.create_head(name, ref).set_tracking_branch(ref) - print('=== Working on: %s ===' % branch, flush=True) - origin.pull(rebase=True) - branch.checkout() - print('branch pulled and checked out') - assert not repo.index.diff(None) - commit = branch.commit - commit_count = 1 - while commit: - if (commit.author.email == 'gccadmin@gcc.gnu.org' - 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: - f.write(current_timestamp) - repo.git.add(datestamp_path) + # 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') - print('branch is done\n', flush=True) + else: + print('DATESTAMP unchanged') + + +if args.current: + print('=== Working on the current branch ===', flush=True) + update_current_branch() +else: + for ref in origin.refs: + assert ref.name.startswith('origin/') + name = ref.name[len('origin/'):] + if name in active_refs: + if name in repo.branches: + branch = repo.branches[name] + else: + branch = repo.create_head(name, ref).set_tracking_branch(ref) + print('=== Working on: %s ===' % branch, flush=True) + origin.pull(rebase=True) + branch.checkout() + print('branch pulled and checked out') + update_current_branch() + assert not repo.index.diff(None) + print('branch is done\n', flush=True)