-
-
Notifications
You must be signed in to change notification settings - Fork 937
Improve scripts and tool configurations #1693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c4df3c
f3be76f
7dd8add
21875b5
0920371
e973f52
be53823
e604b46
19dfbd8
7110bf8
c7cdaf4
f6dbba2
5060c9d
d5479b2
52f9a68
b88d07e
d36818c
4ba5ad1
5d8ddd9
a872d9c
9b9de11
5d15063
6de86a8
f094909
fc96980
b98f15e
7cca7d2
e4e009d
e16e4c0
62c024e
9e245d0
c2472e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ updates: | |
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
interval: "weekly" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,7 @@ jobs: | |
python-version: "3.x" | ||
|
||
- uses: pre-commit/[email protected] | ||
with: | ||
extra_args: --all-files --hook-stage manual | ||
env: | ||
SKIP: black-format |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
repos: | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- flake8-bugbear==23.9.16 | ||
- flake8-comprehensions==3.14.0 | ||
- flake8-typing-imports==1.14.0 | ||
exclude: ^doc|^git/ext/ | ||
- repo: https://github.com/psf/black-pre-commit-mirror | ||
rev: 23.9.1 | ||
hooks: | ||
- id: black | ||
alias: black-check | ||
name: black (check) | ||
args: [--check, --diff] | ||
exclude: ^git/ext/ | ||
stages: [manual] | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: black | ||
alias: black-format | ||
name: black (format) | ||
exclude: ^git/ext/ | ||
|
||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- flake8-bugbear==23.9.16 | ||
- flake8-comprehensions==3.14.0 | ||
- flake8-typing-imports==1.14.0 | ||
exclude: ^doc|^git/ext/ | ||
|
||
- repo: https://github.com/shellcheck-py/shellcheck-py | ||
rev: v0.9.0.5 | ||
hooks: | ||
- id: shellcheck | ||
args: [--color] | ||
exclude: ^git/ext/ | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: check-merge-conflict |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,29 +10,39 @@ trap 'echo "$0: Check failed. Stopping." >&2' ERR | |
readonly version_path='VERSION' | ||
readonly changes_path='doc/source/changes.rst' | ||
|
||
function check_status() { | ||
git status -s "$@" | ||
test -z "$(git status -s "$@")" | ||
} | ||
|
||
function get_latest_tag() { | ||
local config_opts | ||
printf -v config_opts ' -c versionsort.suffix=-%s' alpha beta pre rc RC | ||
EliahKagan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# shellcheck disable=SC2086 # Deliberately word-splitting the arguments. | ||
git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1 | ||
} | ||
|
||
echo 'Checking current directory.' | ||
test "$(cd -- "$(dirname -- "$0")" && pwd)" = "$(pwd)" # Ugly, but portable. | ||
|
||
echo "Checking that $version_path and $changes_path exist and have no uncommitted changes." | ||
test -f "$version_path" | ||
test -f "$changes_path" | ||
git status -s -- "$version_path" "$changes_path" | ||
test -z "$(git status -s -- "$version_path" "$changes_path")" | ||
check_status -- "$version_path" "$changes_path" | ||
|
||
# This section can be commented out, if absolutely necessary. | ||
echo 'Checking that ALL changes are committed.' | ||
git status -s --ignore-submodules | ||
test -z "$(git status -s --ignore-submodules)" | ||
check_status --ignore-submodules | ||
|
||
version_version="$(cat "$version_path")" | ||
version_version="$(<"$version_path")" | ||
changes_version="$(awk '/^[0-9]/ {print $0; exit}' "$changes_path")" | ||
config_opts="$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)" | ||
latest_tag="$(git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1)" | ||
latest_tag="$(get_latest_tag)" | ||
head_sha="$(git rev-parse HEAD)" | ||
latest_tag_sha="$(git rev-parse "${latest_tag}^{commit}")" | ||
|
||
# Display a table of all the current version, tag, and HEAD commit information. | ||
echo $'\nThe VERSION must be the same in all locations, and so must the HEAD and tag SHA' | ||
echo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conveys spacing much better thanks to the separate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did it for spacing, and to to take fuller advantage of Regarding spacing, the table is currently formatted using But that is not necessary in a echo
echo 'The VERSION must be the same in all locations, and so must the HEAD and tag SHA'
echo "VERSION file = $version_version"
echo "changes.rst = $changes_version"
echo "Latest tag = $latest_tag"
echo "HEAD SHA = $head_sha"
echo "Latest tag SHA = $latest_tag_sha" This is arguably more readable, and arguably conveys spacing the best. I'd be happy to change it to this if you like. (Another option could be to go in the opposite direction and make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Since If you think there is benefits to portability assuming that one day CI can perform trusted publishes, I think it's fair to adjust for portability next time you touch them. Otherwise, it would be just as fair to change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The desired interaction of There are not many systems where Making them As you've suggested, next time I work on those scripts I'll look into making them POSIX |
||
echo 'The VERSION must be the same in all locations, and so must the HEAD and tag SHA' | ||
printf '%-14s = %s\n' 'VERSION file' "$version_version" \ | ||
'changes.rst' "$changes_version" \ | ||
'Latest tag' "$latest_tag" \ | ||
|
Uh oh!
There was an error while loading. Please reload this page.