Skip to content

Commit 13b0271

Browse files
authored
Rename .styleguide configs to .wpiformat to match tool name (#257)
1 parent 37ecf9c commit 13b0271

File tree

12 files changed

+59
-27
lines changed

12 files changed

+59
-27
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
rm -rf branch-test
104104
git config --global init.defaultBranch develop
105105
mkdir branch-test && cd branch-test && git init
106-
touch .styleguide && git add .styleguide && git commit -q -m "Initial commit"
106+
touch .wpiformat && git add .wpiformat && git commit -q -m "Initial commit"
107107
if wpiformat; then
108108
exit 1
109109
fi
@@ -115,7 +115,7 @@ jobs:
115115
rm -rf branch-test
116116
git config --global init.defaultBranch develop
117117
mkdir branch-test && cd branch-test && git init
118-
touch .styleguide && git add .styleguide && git commit -q -m "Initial commit"
118+
touch .wpiformat && git add .wpiformat && git commit -q -m "Initial commit"
119119
wpiformat -default-branch develop
120120
121121
# Verify wpiformat reports success if main branch exists
@@ -125,7 +125,7 @@ jobs:
125125
rm -rf branch-test
126126
git config --global init.defaultBranch main
127127
mkdir branch-test && cd branch-test && git init
128-
touch .styleguide && git add .styleguide && git commit -q -m "Initial commit"
128+
touch .wpiformat && git add .wpiformat && git commit -q -m "Initial commit"
129129
wpiformat
130130
131131
# Verify wpiformat reports success if master branch exists
@@ -135,7 +135,7 @@ jobs:
135135
rm -rf branch-test
136136
git config --global init.defaultBranch master
137137
mkdir branch-test && cd branch-test && git init
138-
touch .styleguide && git add .styleguide && git commit -q -m "Initial commit"
138+
touch .wpiformat && git add .wpiformat && git commit -q -m "Initial commit"
139139
wpiformat
140140
141141
- name: Delete branch-test folder
File renamed without changes.
File renamed without changes.

wpiformat/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ pip install wpiformat
2020

2121
## Project Setup
2222

23-
To use these tools with a new project, copy `.styleguide`, and `.styleguide-license` from the examples folder into the project and create a new `.clang-format` file based on the desired C/C++ style.
23+
To use these tools with a new project, copy `.wpiformat`, and `.wpiformat-license` from the examples folder into the project and create a new `.clang-format` file based on the desired C/C++ style.
2424

2525
Note: Since wpiformat already handles include ordering, it is recommended to use `SortIncludes: false` in `.clang-format`.
2626

27-
## .styleguide
27+
## .wpiformat
2828

29-
wpiformat checks the current directory for the `.styleguide` file. If one doesn't exist, all parent directories are tried as well. This file contains groups of filename regular expressions.
29+
wpiformat checks the current directory for the `.wpiformat` file. If one doesn't exist, all parent directories are tried as well. This file contains groups of filename regular expressions.
3030
```
3131
groupName {
3232
regex_here
@@ -36,7 +36,7 @@ The regexes are matched using [re.search()](https://docs.python.org/3/library/re
3636

3737
Empty config groups can be omitted. Directory separators must be "/", not "\\". During processing, they will be replaced internally with an os.sep that is automatically escaped for regexes.
3838

39-
See the `.styleguide` file in the docs/examples directory for all possible groups.
39+
See the `.wpiformat` file in the docs/examples directory for all possible groups.
4040

4141
### Specifying C/C++ files to format
4242

@@ -73,17 +73,17 @@ For example, given a file at `allwpilib/src/main/native/include/wpiutil/support/
7373

7474
The `repoRootNameOverride` group allows one to override the repository name used in include guards. This is useful for giving subprojects within one repository different repository roots in their include guards. Only specify one name in this group because subsequent names will be ignored.
7575

76-
## .styleguide-license
76+
## .wpiformat-license
7777

78-
This file contains the license header template. It should contain `Copyright (c)` followed by the company name and the string `{year}`. See the `.styleguide-license` file in the docs/examples directory.
78+
This file contains the license header template. It should contain `Copyright (c)` followed by the company name and the string `{year}`. See the `.wpiformat-license` file in the docs/examples directory.
7979

80-
wpiformat checks the currently processed file's directory for a `.styleguide` file first and traverses up the directory tree if one isn't found. This allows templates which are closer to the processed file to override a project's main template.
80+
wpiformat checks the currently processed file's directory for a `.wpiformat` file first and traverses up the directory tree if one isn't found. This allows templates which are closer to the processed file to override a project's main template.
8181

8282
### License header semantics
8383

8484
The license header is always at the beginning of the file and ends after two newlines. If there isn't one, or it doesn't contain the required copyright contents, wpiformat inserts a new one containing the current year.
8585

86-
### `.styleguide-license` special variables
86+
### `.wpiformat-license` special variables
8787

8888
`{year}` is replaced with a year range from the earliest copyright year in the file to the current year. If the earliest year is the current year, only that year will be written.
8989

wpiformat/test/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def test_config():
7-
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide")
7+
config_file = Config(os.path.abspath(os.getcwd()), ".wpiformat")
88
assert config_file.is_modifiable_file(
99
"." + os.sep + "wpiformat" + os.sep + "javaguidelink.png"
1010
)

wpiformat/test/test_licenseupdate.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,20 +227,20 @@ def test_licenseupdate():
227227
)
228228

229229
# Ensure excluded files won't be processed
230-
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide")
230+
config_file = Config(os.path.abspath(os.getcwd()), ".wpiformat")
231231
assert not LicenseUpdate().should_process_file(config_file, "./Excluded.h")
232232

233233
# Create git repo to test license years for commits
234234
with OpenTemporaryDirectory():
235235
subprocess.run(["git", "init", "-q"])
236236

237237
# Add base files
238-
with open(".styleguide-license", "w") as file:
238+
with open(".wpiformat-license", "w") as file:
239239
file.write("// Copyright (c) {year}")
240-
with open(".styleguide", "w") as file:
240+
with open(".wpiformat", "w") as file:
241241
file.write("cppSrcFileInclude {\n" + r"\.cpp$")
242-
subprocess.run(["git", "add", ".styleguide-license"])
243-
subprocess.run(["git", "add", ".styleguide"])
242+
subprocess.run(["git", "add", ".wpiformat-license"])
243+
subprocess.run(["git", "add", ".wpiformat"])
244244
subprocess.run(["git", "commit", "-q", "-m", '"Initial commit"'])
245245

246246
# Add file with commit date of last year and range through this year

wpiformat/test/test_tasktest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def run_and_check_file(
2929
input_contents = input_contents.replace("\n", os.linesep)
3030
expected_output_contents = expected_output_contents.replace("\n", os.linesep)
3131

32-
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide")
32+
config_file = Config(os.path.abspath(os.getcwd()), ".wpiformat")
3333

3434
if task.should_process_file(config_file, filename):
3535
output, success = task.run_pipeline(config_file, filename, input_contents)
@@ -59,7 +59,7 @@ def run_and_check_stdout(
5959
expected_output_contents -- expected output file contents
6060
expected_success -- whether run is expected to succeed
6161
"""
62-
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide")
62+
config_file = Config(os.path.abspath(os.getcwd()), ".wpiformat")
6363

6464
if task.should_process_file(config_file, filename):
6565
with redirect_stdout(io.StringIO()) as f:

wpiformat/wpiformat/__init__.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ def proc_pipeline(filename: str) -> bool:
8888
Keyword arguments:
8989
filename -- filename
9090
"""
91-
config_file = Config(os.path.dirname(filename), ".styleguide")
91+
# TODO: Remove handling for deprecated .styleguide file
92+
try:
93+
config_file = Config(os.path.dirname(filename), ".wpiformat")
94+
except OSError:
95+
config_file = Config(os.path.dirname(filename), ".styleguide")
96+
9297
if verbose1 or verbose2:
9398
with print_lock:
9499
print("Processing", filename)
@@ -130,7 +135,12 @@ def proc_standalone(filename: str) -> bool:
130135
Keyword arguments:
131136
filename -- filename
132137
"""
133-
config_file = Config(os.path.dirname(filename), ".styleguide")
138+
# TODO: Remove handling for deprecated .styleguide file
139+
try:
140+
config_file = Config(os.path.dirname(filename), ".wpiformat")
141+
except OSError:
142+
config_file = Config(os.path.dirname(filename), ".styleguide")
143+
134144
if verbose2:
135145
with print_lock:
136146
print("Processing", filename)
@@ -180,7 +190,12 @@ def proc_batch(filenames: list[str]) -> bool:
180190
for subtask in task_pipeline:
181191
work = []
182192
for filename in filenames:
183-
config_file = Config(os.path.dirname(filename), ".styleguide")
193+
# TODO: Remove handling for deprecated .styleguide file
194+
try:
195+
config_file = Config(os.path.dirname(filename), ".wpiformat")
196+
except OSError:
197+
config_file = Config(os.path.dirname(filename), ".styleguide")
198+
184199
if subtask.should_process_file(config_file, filename):
185200
work.append(filename)
186201

@@ -477,7 +492,11 @@ def main():
477492
# Don't run tasks on modifiable or generated files
478493
work = []
479494
for name in files:
480-
config_file = Config(os.path.dirname(name), ".styleguide")
495+
# TODO: Remove handling for deprecated .styleguide file
496+
try:
497+
config_file = Config(os.path.dirname(name), ".wpiformat")
498+
except OSError:
499+
config_file = Config(os.path.dirname(name), ".styleguide")
481500

482501
if config_file.is_modifiable_file(name):
483502
continue

0 commit comments

Comments
 (0)