1
0
Fork 0
Commit graph

10 commits

Author SHA1 Message Date
Peter Hutterer
d73c64a61c check-style: Force the default prefix in git diff
Our match statements rely on the `b/` prefix so let's make sure we
definitely get that one (i.e. undo diff.noprefix).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3658>
2024-03-12 12:47:56 +10:00
Peter Hutterer
49f76f1295 ci: Mark the regex to find chunks in code style checks as regex string
Fixes
    check-style.py:23: SyntaxWarning: invalid escape sequence '\+'
    check-style.py:24: SyntaxWarning: invalid escape sequence '\d'

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3454>
2023-12-15 14:49:57 +00:00
Carlos Garnacho
a41c83be4f 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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2829>
2023-02-20 22:21:01 +00:00
Hunor Csomortáni
3d083655f1 check-style: Improve the proposed git-rebase command
Include the sha used for the dry-run instead of using 'origin/main'.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2733>
2022-12-06 14:08:37 +01:00
Hunor Csomortáni
ce4e58d118 check-style: Use run() instead of Popen()
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>
2022-12-06 14:08:37 +01:00
Hunor Csomortáni
72a1791372 check-style: Don't turn off formatting when the chunk starts on line 1
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>
2022-12-06 14:08:37 +01:00
Hunor Csomortáni
1493bf9610 check-style: Start enumerating lines from 1
This way "the line before start" and "the line before end" can be
expressed as "[start|end] - 1", which looks less like using a magic
number.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2733>
2022-12-06 14:08:37 +01:00
Robert Mader
6960b9b45a ci: Avoid deadlock while reading uncrustify output
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>
2021-08-23 17:40:43 +02:00
Carlos Garnacho
3caa5fea3c ci: Ignore uncrustify calls resulting in unsuccessful return codes
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>
2021-08-23 14:07:30 +02:00
Carlos Garnacho
38f8680817 build: Add script to check code style
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>
2021-08-22 21:26:16 +02:00