summaryrefslogtreecommitdiff
path: root/check-style.py
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-12-07 12:09:25 +0100
committerCarlos Garnacho <carlosg@gnome.org>2022-12-07 12:29:23 +0100
commit1202a14d0250153bae2fb65bb340ae757d677b15 (patch)
treeb85ffc5ca036359b6431b71299dda81942e7e94a /check-style.py
parente974451f39a4dfeccaa61b8e6d75a98c5f9df7a1 (diff)
downloadtracker-1202a14d0250153bae2fb65bb340ae757d677b15.tar.gz
check-style: Allow deciding on individual suggestions with --rewrite
Currently, when the rewrite option is passed, the script does not give much choice on whether changes should be applied or not, it just does "git comit -a --amend". However, uncrustify is not always entirely right about the proposed style changes, or it might suggest changes in distant/unrelated bits in the changed functions. Thus the developer needs to be given some option. Change the approach of the --rewrite option, so that it first does "git add -p", so that individual changes may be decided upon, and after all the chunks were gone through, uses "git commit --squash" so that the changes may be reviewed before manually doing "git rebase --autosquash" to merge the changes.
Diffstat (limited to 'check-style.py')
-rwxr-xr-xcheck-style.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/check-style.py b/check-style.py
index c68927241..5ffa18f00 100755
--- a/check-style.py
+++ b/check-style.py
@@ -143,13 +143,21 @@ chunks = find_chunks(diff)
changed = reformat_chunks(chunks, rewrite)
if dry_run is not True and rewrite is True:
- subprocess.run(["git", "commit", "--all", "--amend", "-C", "HEAD"], stdout=subprocess.DEVNULL)
+ proc = subprocess.run(["git", "add", "-p"])
+ if proc.returncode == 0:
+ # Commit the added changes as a squash commit
+ subprocess.run(
+ ["git", "commit", "--squash", "HEAD", "-C", "HEAD"],
+ stdout=subprocess.DEVNULL)
+ # Delete the unapplied changes
+ subprocess.run(["git", "reset", "--hard"], stdout=subprocess.DEVNULL)
os._exit(0)
elif dry_run is True and changed is True:
print(f"""
-Issue the following command in your local tree to apply the suggested changes:
+Issue the following commands in your local tree to apply the suggested changes:
$ git rebase {sha} --exec "./check-style.py -r"
+ $ git rebase --autosquash {sha}
""")
os._exit(-1)