Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 5ce03c7

Browse files
committed
Rename placeholder variables
I confused %PROJECT_NAME% and %PROJECT_URLNAME% too many times, and decided to stop it by naming them in a way that I hope makes it more obvious what they are.
1 parent 0952ae8 commit 5ce03c7

22 files changed

+89
-83
lines changed

.flake8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @brief Project-wide Flake8 configuration
44
# @created %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
#
88
# Note: as of version 4.0, flake8 does NOT read global configuration files
99
# from ~/.flake8 or ~/.config/flake8. If you had such a config file of your
@@ -47,4 +47,4 @@ per-file-ignores =
4747
# keyword/parameter equals"). It would be better to disable E251 just for
4848
# that block in the file, BUT flake8 only recognizes per-line annotations,
4949
# so there's no way to tell it to ignore a rule only for a block of code.
50-
%PROJECT_NAME%/__main__.py: E251
50+
%MODULE_NAME%/__main__.py: E251

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ Please summarize what this pull request is about, and what it changes.
55
### Details
66

77
Describe more about the changes you made:
8-
1. (...)
9-
2. (...)
108

119
### Software versions
1210

.github/rename_project.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
# The original file was copied on 2021-10-14.
1212
# =============================================================================
1313

14-
while getopts a:e:n:u:d: flag
15-
do
14+
while getopts a:e:n:u:d: flag; do
1615
case "${flag}" in
1716
a) author=${OPTARG};;
18-
e) email=${OPTARG};;
19-
n) project_name=${OPTARG};;
20-
u) urlname=${OPTARG};;
2117
d) description=${OPTARG};;
18+
e) email=${OPTARG};;
19+
m) module_name=${OPTARG};;
20+
r) repo_name=${OPTARG};;
2221
esac
2322
done
2423

@@ -32,32 +31,34 @@ echo "Author name: $author"
3231
echo "Author first name: $first_name"
3332
echo "Author family name: $family_name"
3433
echo "Author email: $email"
35-
echo "Project name: $project_name"
36-
echo "Project URL name: $urlname"
34+
echo "Repo name: $repo_name"
35+
echo "Module name: $module_name"
3736
echo "Description: $description"
3837
echo "Creation date: $creation_date"
3938
echo "Creation year: $creation_year"
4039

41-
echo "Renaming project ..."
40+
echo "Performing substitutions in files ..."
4241

4342
for filename in $(git ls-files)
4443
do
4544
sed -i "s/%AUTHOR_NAME%/$author/g" $filename
4645
sed -i "s/%AUTHOR_EMAIL%/$email/g" $filename
4746
sed -i "s/%AUTHOR_FIRST_NAME%/$first_name/g" $filename
4847
sed -i "s/%AUTHOR_FAMILY_NAME%/$family_name/g" $filename
49-
sed -i "s/%PROJECT_NAME%/$project_name/g" $filename
50-
sed -i "s/%PROJECT_URLNAME%/$urlname/g" $filename
51-
sed -i "s/%PROJECT_DESCRIPTION%/$description/g" $filename
48+
sed -i "s/%REPO_NAME%/$repo_name/g" $filename
49+
sed -i "s/%DESCRIPTION%/$description/g" $filename
50+
sed -i "s/%MODULE_NAME%/$module_name/g" $filename
5251
sed -i "s/%CREATION_DATE%/$creation_date/g" $filename
5352
sed -i "s/%CREATION_YEAR%/$creation_year/g" $filename
54-
echo "Performed substitutions in $filename"
53+
echo "Finished substitutions in $filename"
5554
done
5655

57-
mv project_name $project_name
56+
echo "Renaming files and directories ..."
57+
58+
mv module_name $module_name
5859
rm -f codemeta.json
5960
mv codemeta-TEMPLATE.json codemeta.json
6061
rm -f CITATION.cff
6162
mv CITATION-TEMPLATE.cff CITATION.cff
6263

63-
echo "Renaming project ... Done."
64+
echo "Renaming ... Done."

.github/workflows/rename_project.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ jobs:
3131
# Token needs to be set in order to use the GitHub CLI `gh` program.
3232
GH_TOKEN: ${{ github.token }}
3333
run: |
34-
echo NAME="$(gh repo view --json name -q .name | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
35-
echo URLNAME="$(gh repo view --json name -q .name)" >> $GITHUB_ENV
36-
echo AUTHOR="$(gh api https://api.github.com/users/${{ github.actor }} -q .name)" >> $GITHUB_ENV
37-
echo EMAIL="$(gh api https://api.github.com/users/${{ github.actor }} -q .email)" >> $GITHUB_ENV
38-
echo DESCRIPTION="$(gh repo view --json description -q .description)" >> $GITHUB_ENV
34+
# The meanings of the variables:
35+
# REPO_NAME = the repository name used on GitHub at creation time
36+
# MODULE_NAME = like NAME but all lower-case
37+
# DESCRIPTION = the description given on GitHub at creation time
38+
# AUTHOR = the name of the author
39+
# EMAIL = the email address of the author
40+
41+
echo REPO_NAME="$(gh repo view --json name -q .name)" >> $GITHUB_ENV
42+
echo MODULE_NAME="$(gh repo view --json name -q .name | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
43+
echo DESCRIPTION="$(gh repo view --json description -q .description)" >> $GITHUB_ENV
44+
echo AUTHOR="$(gh api https://api.github.com/users/${{ github.actor }} -q .name)" >> $GITHUB_ENV
45+
echo EMAIL="$(gh api https://api.github.com/users/${{ github.actor }} -q .email)" >> $GITHUB_ENV
3946
4047
- name: Test that this is a repo based on our template.
4148
id: check_template
@@ -48,7 +55,7 @@ jobs:
4855
shell: bash
4956
run: |
5057
echo "Performing substitutions."
51-
.github/rename_project.sh -a "${{ env.AUTHOR }}" -e "${{ env.EMAIL }}" -n "${{ env.NAME }}" -u "${{ env.URLNAME }}" -d "${{ env.DESCRIPTION }}"
58+
.github/rename_project.sh -a "${{ env.AUTHOR }}" -e "${{ env.EMAIL }}" -r "${{ env.REPO_NAME }}" -m "${{ env.MODULE_NAME }}" -d "${{ env.DESCRIPTION }}"
5259
5360
- name: Clean up.
5461
shell: bash

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @brief Files and patterns for files and subdirs that git should ignore
44
# @date %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
#
88
# The approach we suggest is to add ONLY project-specific rules here. Put
99
# rules that apply to your way of doing things (and the particular tools you

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Change log for %PROJECT_NAME%
1+
# Change log for %REPO_NAME%
22

33
## Version 0.0.0 (%CREATION_DATE%)
44

5-
Project repository created at https://github.com/caltechlibrary/%PROJECT_URLNAME%
5+
Project repository created at https://github.com/caltechlibrary/%REPO_NAME%
66
by %AUTHOR_NAME%.

CITATION-TEMPLATE.cff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
cff-version: 1.2
22
message: "If you use this software, please cite it using these metadata."
3-
title: "%PROJECT_NAME%"
3+
title: "%REPO_NAME%"
44
authors:
55
- family-names: %AUTHOR_FAMILY_NAME%
66
given-names: %AUTHOR_FIRST_NAME%
77
affiliation: "Caltech Library"
88
orcid: "https://orid.org/YOUR-ORCID-NUMBER"
99
version: "0.0.0"
10-
abstract: "%PROJECT_DESCRIPTION%"
11-
repository-code: "https://github.com/caltechlibrary/%PROJECT_URLNAME%"
10+
abstract: "%DESCRIPTION%"
11+
repository-code: "https://github.com/caltechlibrary/%REPO_NAME%"
1212
type: software
13-
license-url: "https://github.com/caltechlibrary/%PROJECT_URLNAME%/blob/main/LICENSE"
13+
license-url: "https://github.com/caltechlibrary/%REPO_NAME%/blob/main/LICENSE"
1414
keywords:
1515
- "KEYWORDS"
1616
date-released: "RELEASE-DATE"

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ authors:
2323
family-names: Keswick
2424
orcid: "https://orcid.org/0000-0001-5644-440X"
2525
version: "1.9.0"
26-
abstract: "GitHub template project for non-web Python application projects"
26+
abstract: "GitHub repository template for non-web Python programs"
2727
repository-code: "https://github.com/caltechlibrary/py-cli-template"
2828
type: software
2929
license-url: "https://github.com/caltechlibrary/py-cli-template/blob/main/LICENSE"

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Guidelines for contributing to this project
1+
# Guidelines for contributing to this project repository
22

33
Any constructive contributions – bug reports, pull requests (code or documentation), suggestions for improvements, and more – are welcome.
44

@@ -8,7 +8,7 @@ Everyone is asked to read and respect the [code of conduct](CODE_OF_CONDUCT.md)
88

99
## Coordinating work
1010

11-
A quick way to find out what is currently in the near-term plans for this project is to look at the [GitHub issue tracker](https://github.com/caltechlibrary/%PROJECT_URLNAME%/issues), but the possibilities are not limited to what you see there – if you have ideas for new features and enhancements, please feel free to write them up as a new issue or contact the developers directly!
11+
A quick way to find out what is currently in the near-term plans for this project is to look at the [GitHub issue tracker](https://github.com/caltechlibrary/%REPO_NAME%/issues), but the possibilities are not limited to what you see there – if you have ideas for new features and enhancements, please feel free to write them up as a new issue or contact the developers directly!
1212

1313
## Submitting contributions
1414

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @brief Makefile for some steps in creating new releases on GitHub
44
# @date %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
# =============================================================================
88

99
.ONESHELL: # Run all commands in the same shell.
@@ -146,10 +146,10 @@ report: vars
146146
# make lint & make test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147147

148148
lint:
149-
flake8 %PROJECT_URLNAME%
149+
flake8 %MODULE_NAME%
150150

151151
test tests:;
152-
pytest -v --cov=%PROJECT_URLNAME% -l tests/
152+
pytest -v --cov=%MODULE_NAME% -l tests/
153153

154154

155155
# make install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)