File tree Expand file tree Collapse file tree 3 files changed +35
-12
lines changed Expand file tree Collapse file tree 3 files changed +35
-12
lines changed Original file line number Diff line number Diff line change 1818 - uses : pre-commit/action@v3.0.1
1919 - run : |
2020 python -m pip install 'ruamel.yaml'
21- if ! python sort_regressionfiles_yaml.py > regressionfiles.diff; then
22- echo "difference found:"
23- cat regressionfiles.diff
24- if ! patch -p1 -i regressionfiles.diff regressionfiles.yaml; then
25- echo "patch didn't apply cleanly"
26- else
27- echo "patch applied cleanly"
28- fi
29- exit 1
30- fi
21+ ./sort_regressionfiles_yaml.sh
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
3+ """sort_regressionfiles_yaml.py: Check and see if the entries in
4+ regressionfiles.yaml are sorted by filename, producing the diff to standard
5+ out that should make them sorted.
6+
7+ You should probably call the shell script, which wraps this Python code.
8+ """
9+
310
411if __name__ == "__main__" :
512 import sys
1623
1724 contents_sorted = {"regressions" : sorted (contents ["regressions" ], key = lambda x : x ["loc_entry" ])}
1825
26+ # Since the original regressionfiles.yaml has comments, we need to strip
27+ # those out before generating the diff, since we can't yet generated
28+ # sorted output that contains comments.
29+
1930 with open ("regressionfiles_nocomments.yaml" , "w" , encoding = "utf-8" ) as handle :
2031 yaml .dump (contents , handle )
2132
2435
2536 result = sp .run (
2637 [
27- "git" ,
2838 "diff" ,
29- "--no-index " ,
39+ "-u " ,
3040 "regressionfiles_nocomments.yaml" ,
3141 "regressionfiles_sorted.yaml" ,
3242 ]
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -euo pipefail
4+
5+ # sort_regressionfiles_yaml.sh: Check and see if the entries in
6+ # regressionfiles.yaml are sorted by filename, producing a diff file that
7+ # should make them sorted. Then, attempt to apply the diff as a patch that
8+ # would make regressionfiles.yaml sorted, which may fail depending on any
9+ # comments present in the original file.
10+ #
11+ # You should probably call this shell script and not the Python code.
12+
13+ if ! python sort_regressionfiles_yaml.py > regressionfiles.diff; then
14+ echo " difference found:"
15+ cat regressionfiles.diff
16+ if ! patch -p1 -i regressionfiles.diff regressionfiles.yaml; then
17+ echo " patch didn't apply cleanly"
18+ else
19+ echo " patch applied cleanly"
20+ fi
21+ exit 1
22+ fi
You can’t perform that action at this time.
0 commit comments