aboutsummaryrefslogtreecommitdiff
path: root/contrib/gcc-changelog
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-05-26 12:11:24 +0200
committerMartin Liska <mliska@suse.cz>2020-05-26 12:13:13 +0200
commitc8462662da25f2cb8de0e4fe82ec5880041f38f2 (patch)
treeb14895896fe86475ef3c664b7280ab9be64a73f7 /contrib/gcc-changelog
parent5c8344e7289969e1ee3103beaf9631b284f5ebc3 (diff)
downloadgcc-c8462662da25f2cb8de0e4fe82ec5880041f38f2.zip
gcc-c8462662da25f2cb8de0e4fe82ec5880041f38f2.tar.gz
gcc-c8462662da25f2cb8de0e4fe82ec5880041f38f2.tar.bz2
Support --dry-mode in git_update_version.py.
The patch improves the script based on Jakub's needs, I'm going to install the patch. contrib/ChangeLog: * gcc-changelog/git_update_version.py: Add 2 new options.
Diffstat (limited to 'contrib/gcc-changelog')
-rwxr-xr-xcontrib/gcc-changelog/git_update_version.py43
1 files changed, 31 insertions, 12 deletions
diff --git a/contrib/gcc-changelog/git_update_version.py b/contrib/gcc-changelog/git_update_version.py
index ee3989b..3dcc5625 100755
--- a/contrib/gcc-changelog/git_update_version.py
+++ b/contrib/gcc-changelog/git_update_version.py
@@ -31,7 +31,7 @@ def read_timestamp(path):
return open(path).read()
-def prepend_to_changelog_files(repo, folder, git_commit):
+def prepend_to_changelog_files(repo, folder, git_commit, add_to_git):
if not git_commit.success:
for error in git_commit.errors:
print(error)
@@ -48,7 +48,8 @@ def prepend_to_changelog_files(repo, folder, git_commit):
if content:
f.write('\n\n')
f.write(content)
- repo.git.add(full_path)
+ if add_to_git:
+ repo.git.add(full_path)
active_refs = ['master', 'releases/gcc-8', 'releases/gcc-9', 'releases/gcc-10']
@@ -57,6 +58,12 @@ parser = argparse.ArgumentParser(description='Update DATESTAMP and generate '
'ChangeLog entries')
parser.add_argument('-g', '--git-path', default='.',
help='Path to git repository')
+parser.add_argument('-p', '--push', action='store_true',
+ help='Push updated active branches')
+parser.add_argument('-d', '--dry-mode',
+ help='Generate patch for ChangeLog entries and do it'
+ ' even if DATESTAMP is unchanged; folder argument'
+ ' is expected')
args = parser.parse_args()
repo = Repo(args.git_path)
@@ -86,19 +93,31 @@ for ref in origin.refs:
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:')
+ 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)
- # 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
- # repo.git.push('origin', branch)
+ 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)
+ 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)