mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-13 12:23:38 +01:00
chore(repo): one rustfmt, toolchain, gitignore and licence; format-all checks one group
komorebi-for-kde and komorebi-for-mac each had a rustfmt.toml (the root one minus newline_style), a rust-toolchain.toml and .envrc (identical to the root's), a .gitignore and a LICENSE.md; they are deleted, and the root .gitignore gains the KDE entries (/.vm, __pycache__/, *.pyc). tools/format-all now has one group: every .rs file of the repository, file by file with skip_children, with the root rustfmt.toml and the dev shell's nightly (the --tree option is gone). Verified: tools/format-all --check passes on the whole tree (the formatting of the six files edited in the path-fix revision was applied to that revision).
This commit is contained in:
1 parent
d726ec8ddb
commit
73c43239b5
12 files changed
+19
-287
No files matched your search
+6
-1
@@ -9,6 +9,11 @@ komorebic/applications.yaml
|
||||
/komorebi-schema
|
||||
/.wrangler
|
||||
/.xwin-cache
|
||||
result
|
||||
/result*
|
||||
/.direnv
|
||||
procdump.exe
|
||||
|
||||
# KDE VM tests, Python bytecode
|
||||
/.vm
|
||||
__pycache__/
|
||||
*.pyc
|
||||
@@ -1 +0,0 @@
|
||||
use flake
|
||||
@@ -1,8 +0,0 @@
|
||||
/target
|
||||
/result*
|
||||
/.direnv
|
||||
/.vm
|
||||
|
||||
# Python bytecode
|
||||
__pycache__/
|
||||
*.pyc
|
||||
@@ -1,108 +0,0 @@
|
||||
# Komorebi License
|
||||
|
||||
Version 2.0.0
|
||||
|
||||
## Acceptance
|
||||
|
||||
In order to get any license under these terms, you must agree
|
||||
to them as both strict obligations and conditions to all
|
||||
your licenses.
|
||||
|
||||
## Copyright License
|
||||
|
||||
The licensor grants you a copyright license for the software
|
||||
to do everything you might do with the software that would
|
||||
otherwise infringe the licensor's copyright in it for any
|
||||
permitted purpose. However, you may only distribute the source
|
||||
code of the software according to the [Distribution License](
|
||||
#distribution-license), you may only make changes according
|
||||
to the [Changes License](#changes-license), and you may not
|
||||
otherwise distribute the software or new works based on the
|
||||
software.
|
||||
|
||||
## Distribution License
|
||||
|
||||
The licensor grants you an additional copyright license to
|
||||
distribute copies of the source code of the software. Your
|
||||
license to distribute covers distributing the source code of
|
||||
the software with changes permitted by the [Changes License](
|
||||
#changes-license).
|
||||
|
||||
## Changes License
|
||||
|
||||
The licensor grants you an additional copyright license to
|
||||
make changes for any permitted purpose.
|
||||
|
||||
## Patent License
|
||||
|
||||
The licensor grants you a patent license for the software that
|
||||
covers patent claims the licensor can license, or becomes able
|
||||
to license, that you would infringe by using the software.
|
||||
|
||||
## Personal Uses
|
||||
|
||||
Personal use for research, experiment, and testing for
|
||||
the benefit of public knowledge, personal study, private
|
||||
entertainment, hobby projects, amateur pursuits, or religious
|
||||
observance, without any anticipated commercial application,
|
||||
is use for a permitted purpose.
|
||||
|
||||
## Fair Use
|
||||
|
||||
You may have "fair use" rights for the software under the
|
||||
law. These terms do not limit them.
|
||||
|
||||
## No Other Rights
|
||||
|
||||
These terms do not allow you to sublicense or transfer any of
|
||||
your licenses to anyone else, or prevent the licensor from
|
||||
granting licenses to anyone else. These terms do not imply
|
||||
any other licenses.
|
||||
|
||||
## Patent Defense
|
||||
|
||||
If you make any written claim that the software infringes or
|
||||
contributes to infringement of any patent, your patent license
|
||||
for the software granted under these terms ends immediately. If
|
||||
your company makes such a claim, your patent license ends
|
||||
immediately for work on behalf of your company.
|
||||
|
||||
## Violations
|
||||
|
||||
The first time you are notified in writing that you have
|
||||
violated any of these terms, or done anything with the software
|
||||
not covered by your licenses, your licenses can nonetheless
|
||||
continue if you come into full compliance with these terms,
|
||||
and take practical steps to correct past violations, within
|
||||
32 days of receiving notice. Otherwise, all your licenses
|
||||
end immediately.
|
||||
|
||||
## No Liability
|
||||
|
||||
***As far as the law allows, the software comes as is, without
|
||||
any warranty or condition, and the licensor will not be liable
|
||||
to you for any damages arising out of these terms or the use
|
||||
or nature of the software, under any kind of legal claim.***
|
||||
|
||||
## Definitions
|
||||
|
||||
The **licensor** is the individual or entity offering these
|
||||
terms, and the **software** is the software the licensor makes
|
||||
available under these terms.
|
||||
|
||||
**You** refers to the individual or entity agreeing to these
|
||||
terms.
|
||||
|
||||
**Your company** is any legal entity, sole proprietorship,
|
||||
or other kind of organization that you work for, plus all
|
||||
organizations that have control over, are under the control of,
|
||||
or are under common control with that organization. **Control**
|
||||
means ownership of substantially all the assets of an entity,
|
||||
or the power to direct its management and policies by vote,
|
||||
contract, or otherwise. Control can be direct or indirect.
|
||||
|
||||
**Your licenses** are all the licenses granted to you for the
|
||||
software under these terms.
|
||||
|
||||
**Use** means anything you do with the software requiring one
|
||||
of your licenses.
|
||||
@@ -1,2 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
@@ -1 +0,0 @@
|
||||
imports_granularity = "Item"
|
||||
@@ -1 +0,0 @@
|
||||
use flake
|
||||
@@ -1,6 +0,0 @@
|
||||
/target
|
||||
/result*
|
||||
/.idea
|
||||
/.direnv
|
||||
/komorebi-schema
|
||||
/bar-schema
|
||||
@@ -1,108 +0,0 @@
|
||||
# Komorebi License
|
||||
|
||||
Version 2.0.0
|
||||
|
||||
## Acceptance
|
||||
|
||||
In order to get any license under these terms, you must agree
|
||||
to them as both strict obligations and conditions to all
|
||||
your licenses.
|
||||
|
||||
## Copyright License
|
||||
|
||||
The licensor grants you a copyright license for the software
|
||||
to do everything you might do with the software that would
|
||||
otherwise infringe the licensor's copyright in it for any
|
||||
permitted purpose. However, you may only distribute the source
|
||||
code of the software according to the [Distribution License](
|
||||
#distribution-license), you may only make changes according
|
||||
to the [Changes License](#changes-license), and you may not
|
||||
otherwise distribute the software or new works based on the
|
||||
software.
|
||||
|
||||
## Distribution License
|
||||
|
||||
The licensor grants you an additional copyright license to
|
||||
distribute copies of the source code of the software. Your
|
||||
license to distribute covers distributing the source code of
|
||||
the software with changes permitted by the [Changes License](
|
||||
#changes-license).
|
||||
|
||||
## Changes License
|
||||
|
||||
The licensor grants you an additional copyright license to
|
||||
make changes for any permitted purpose.
|
||||
|
||||
## Patent License
|
||||
|
||||
The licensor grants you a patent license for the software that
|
||||
covers patent claims the licensor can license, or becomes able
|
||||
to license, that you would infringe by using the software.
|
||||
|
||||
## Personal Uses
|
||||
|
||||
Personal use for research, experiment, and testing for
|
||||
the benefit of public knowledge, personal study, private
|
||||
entertainment, hobby projects, amateur pursuits, or religious
|
||||
observance, without any anticipated commercial application,
|
||||
is use for a permitted purpose.
|
||||
|
||||
## Fair Use
|
||||
|
||||
You may have "fair use" rights for the software under the
|
||||
law. These terms do not limit them.
|
||||
|
||||
## No Other Rights
|
||||
|
||||
These terms do not allow you to sublicense or transfer any of
|
||||
your licenses to anyone else, or prevent the licensor from
|
||||
granting licenses to anyone else. These terms do not imply
|
||||
any other licenses.
|
||||
|
||||
## Patent Defense
|
||||
|
||||
If you make any written claim that the software infringes or
|
||||
contributes to infringement of any patent, your patent license
|
||||
for the software granted under these terms ends immediately. If
|
||||
your company makes such a claim, your patent license ends
|
||||
immediately for work on behalf of your company.
|
||||
|
||||
## Violations
|
||||
|
||||
The first time you are notified in writing that you have
|
||||
violated any of these terms, or done anything with the software
|
||||
not covered by your licenses, your licenses can nonetheless
|
||||
continue if you come into full compliance with these terms,
|
||||
and take practical steps to correct past violations, within
|
||||
32 days of receiving notice. Otherwise, all your licenses
|
||||
end immediately.
|
||||
|
||||
## No Liability
|
||||
|
||||
***As far as the law allows, the software comes as is, without
|
||||
any warranty or condition, and the licensor will not be liable
|
||||
to you for any damages arising out of these terms or the use
|
||||
or nature of the software, under any kind of legal claim.***
|
||||
|
||||
## Definitions
|
||||
|
||||
The **licensor** is the individual or entity offering these
|
||||
terms, and the **software** is the software the licensor makes
|
||||
available under these terms.
|
||||
|
||||
**You** refers to the individual or entity agreeing to these
|
||||
terms.
|
||||
|
||||
**Your company** is any legal entity, sole proprietorship,
|
||||
or other kind of organization that you work for, plus all
|
||||
organizations that have control over, are under the control of,
|
||||
or are under common control with that organization. **Control**
|
||||
means ownership of substantially all the assets of an entity,
|
||||
or the power to direct its management and policies by vote,
|
||||
contract, or otherwise. Control can be direct or indirect.
|
||||
|
||||
**Your licenses** are all the licenses granted to you for the
|
||||
software under these terms.
|
||||
|
||||
**Use** means anything you do with the software requiring one
|
||||
of your licenses.
|
||||
@@ -1,2 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
@@ -1 +0,0 @@
|
||||
imports_granularity = "Item"
|
||||
+13
-48
@@ -1,40 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# format-all: the formatting checks of the nix flakes, runnable locally, and the fix for them.
|
||||
# format-all: the formatting check of the nix flake, runnable locally, and the fix for it.
|
||||
#
|
||||
# Usage: tools/format-all [--check | --apply] [--tree windows|kde|mac|all] [--root DIR]
|
||||
# Usage: tools/format-all [--check | --apply] [--root DIR]
|
||||
# --check (default) fails if any file is not formatted; prints the diff
|
||||
# --apply formats the files in place (do it LAST on a candidate: it touches many files)
|
||||
# --tree which flake's check to reproduce (default all)
|
||||
# --root the repository (default: the one this script is in; the nix check passes its source)
|
||||
#
|
||||
# The checks use the nightly rustfmt (rustfmt.toml has nightly options) and edition 2024, the
|
||||
# edition of every manifest:
|
||||
# windows every .rs file of the Windows crates with the root rustfmt.toml, file by file
|
||||
# (skip_children: the entry files name modules of other platforms that are not in the
|
||||
# Windows source, which rustfmt would fail to find); the linux and macos modules of the
|
||||
# shared crates belong to the kde and mac trees
|
||||
# mac komorebi-for-mac/**/*.rs and the macos modules of the shared crates, with
|
||||
# komorebi-for-mac/rustfmt.toml
|
||||
# kde komorebi-for-kde/**/*.rs and the linux modules of the shared crates, with
|
||||
# komorebi-for-kde/rustfmt.toml (the same file-by-file invocation as the mac one; the nix
|
||||
# check runs this script with the rustfmt of the flake's own nightly, fmtToolchain)
|
||||
# Every .rs file of the repository is formatted with the root rustfmt.toml, one file at a time with
|
||||
# skip_children (the entry files of a crate name modules of other platforms, and a cfg_select! arm that is
|
||||
# not compiled is not a module rustfmt can follow), by the nightly rustfmt and edition 2024, the edition of
|
||||
# every manifest.
|
||||
# The nightly rustfmt is $RUSTFMT if set, else the one of the dev shell of the root flake (`nix develop`),
|
||||
# which is the nightly of the pinned rust-overlay that the nix checks use (the flake of each tree pins the
|
||||
# same revision; another nightly may format differently and may not follow cfg_select), else a nightly
|
||||
# `rustfmt` on PATH.
|
||||
# which is the nightly of the pinned rust-overlay that the nix check uses (another nightly may format
|
||||
# differently and may not follow cfg_select), else a nightly `rustfmt` on PATH.
|
||||
set -uo pipefail
|
||||
|
||||
orig_args=("$@")
|
||||
mode=check
|
||||
tree=all
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--check) mode=check ;;
|
||||
--apply) mode=apply ;;
|
||||
--tree) tree=$2; shift ;;
|
||||
--root) root=$2; shift ;;
|
||||
-h | --help) sed -n 2,23p "$0"; exit 0 ;;
|
||||
-h | --help) sed -n 2,16p "$0"; exit 0 ;;
|
||||
*) echo "format-all: unknown argument $1" >&2; exit 2 ;;
|
||||
esac
|
||||
shift
|
||||
@@ -57,32 +46,8 @@ cd "$root" || exit 2
|
||||
|
||||
flag=--check
|
||||
[ "$mode" = apply ] && flag=
|
||||
status=0
|
||||
|
||||
# the linux and macos modules of the shared crates (the Windows source filter of flake.nix leaves them out)
|
||||
other_platform='(^|/)(komorebic/src/(linux|macos)|komorebic/tests/(linux|macos)_|komorebi-client/src/(linux|macos)\.rs|komorebi-client/tests/(linux|macos)_|komorebi-bar/src/macos|komorebi-daemon/tests/(linux|macos)_)'
|
||||
|
||||
rs_files() { find . -name '*.rs' -not -path '*/target/*' -not -path './.git/*' -not -path './.jj/*' | sed 's|^\./||' | sort; }
|
||||
|
||||
run_rustfmt() { # config-file, files on stdin
|
||||
local cfg=$1 files
|
||||
mapfile -t files
|
||||
[ ${#files[@]} -eq 0 ] && { echo "format-all: no files for $cfg" >&2; return 1; }
|
||||
"$RUSTFMT" --edition 2024 --config-path "$cfg" --config skip_children=true $flag "${files[@]}"
|
||||
}
|
||||
|
||||
if [ "$tree" = windows ] || [ "$tree" = all ]; then
|
||||
echo "format-all: windows"
|
||||
rs_files | grep -v '^komorebi-for-\(kde\|mac\)/' | grep -Ev "$other_platform" | run_rustfmt rustfmt.toml || status=1
|
||||
fi
|
||||
if [ "$tree" = mac ] || [ "$tree" = all ]; then
|
||||
echo "format-all: mac"
|
||||
{ rs_files | grep '^komorebi-for-mac/'; rs_files | grep -E "^(komorebic/src/macos|komorebi-bar/src/macos|komorebi-client/src/macos\.rs)"; } \
|
||||
| run_rustfmt komorebi-for-mac/rustfmt.toml || status=1
|
||||
fi
|
||||
if [ "$tree" = kde ] || [ "$tree" = all ]; then
|
||||
echo "format-all: kde"
|
||||
{ rs_files | grep '^komorebi-for-kde/'; rs_files | grep -E "^(komorebic/src/linux|komorebic/tests/linux_|komorebi-client/src/linux\.rs|komorebi-client/tests/linux_)"; } \
|
||||
| run_rustfmt komorebi-for-kde/rustfmt.toml || status=1
|
||||
fi
|
||||
exit $status
|
||||
echo "format-all: all"
|
||||
mapfile -t files < <(find . -name '*.rs' -not -path '*/target/*' -not -path './.git/*' -not -path './.jj/*' | sed 's|^\./||' | sort)
|
||||
[ ${#files[@]} -eq 0 ] && { echo "format-all: no files" >&2; exit 1; }
|
||||
"$RUSTFMT" --edition 2024 --config-path rustfmt.toml --config skip_children=true $flag "${files[@]}"
|
||||
Reference in new issue
Block a user