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.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2829>
The Python docs recommends using run() for all use-cases it can handle:
https://docs.python.org/3/library/subprocess.html#using-the-subprocess-module
run() waits for the subprocess started to complete, so it's not
necessary to use wait() and communicate() anymore. This simplifies the
script.
Previously running "check-style.py -r" after each commit in an
interactive rebase failed, b/c the script did not wait for the amend
command to complete. Using run() instead of Popen() solves this issue.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2733>
Before this, new files introduced by the range of commits checked were
not considered for formatting b/c uncrustify was always turned off in
the beginning of the files, and never turned back on.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2733>
The docu for `Popen.wait()` says:
> This will deadlock when using stdout=PIPE and/or stderr=PIPE and
> the child process generates enough output to a pipe such that it
> blocks waiting for the OS pipe buffer to accept more data.
Fixes 3caa5fea3c
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1971>
If for some reason uncrustify gets angry at our file and indent on/off
marks, it will result in an error code other than 0. Since in those
cases there is no output to diff with, we misinterpret those situations
as "the whole file should be deleted", which is far from it.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1970>
Borrowed from Tracker, this script has different mode usages:
* --sha allows specifying a commit SHA, HEAD^ by default.
* --dry-run shows suggested changes in stdout, by default
the local tree is changed.
* --rewrite amends the last commit, in addition to performing
the changes.
This allows from simple style checks in the development tree,
automatically rewriting with the suggested changes (e.g. with
`git rebase --exec ./check-style -r`) and CI integration.
The script has per-function granularity, and works by re-styling
individually every commit, and inside every commit every chunk.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1924>