Skip to content
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

Renaming github_username to github_owner + generating __repo_name & __repo_url #409

Merged
merged 11 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
"project_short_description": "A cookiecutter package with UCL ARC recommendations.",
"initialise_git_repository": true,
"deploy_docs_to_github_pages": false,
"github_username": "{{cookiecutter.author_given_names.lower().replace(' ', '-')}}-{{cookiecutter.author_family_names.lower().replace(' ', '-')}}",
"github_owner": "{{cookiecutter.author_given_names.lower().replace(' ', '-')}}-{{cookiecutter.author_family_names.lower().replace(' ', '-')}}",
"min_python_version": ["3.10", "3.11", "3.12"],
"max_python_version": ["3.12", "3.11", "3.10"],
"license": ["MIT", "BSD-3", "GPL-3.0"],
"funder": "JBFC: The Joe Bloggs Funding Council",
"__repo_name": "{{cookiecutter.github_owner}}/{{cookiecutter.project_slug}}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL __variable in cookiecutter.json, looks so clean!

"__repo_url": "https://github.com/{{cookiecutter.__repo_name}}",
"__prompts__": {
"author_given_names": "Given name(s) of package author",
"author_family_names": "Family name(s) of package author",
Expand All @@ -23,7 +25,7 @@
"project_short_description": "Short description of the project",
"initialise_git_repository": "Initialise project directory as a Git repository?",
"deploy_docs_to_github_pages": "Automatically deploy HTML docs to GitHub Pages on pushes to main?",
"github_username": "GitHub user or organization name which will be owner of repository",
"github_owner": "GitHub user or organization name which will be owner of repository",
"min_python_version": "Minimum Python version supported by package",
"max_python_version": "Maximum Python version supported by package",
"license": "Which open-source license to release package under",
Expand Down
12 changes: 5 additions & 7 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main(initialise_git_repository: str, deploy_docs_to_github_pages: str) -> in
print(
"GitHub CLI detected, you can create a repo with the following:\n\n"
"gh repo create "
"{{cookiecutter.github_username}}/{{cookiecutter.project_slug}} "
"{{cookiecutter.__repo_name}} "
"-d '{{cookiecutter.project_short_description}}' "
"--public "
"-r origin "
Expand All @@ -73,12 +73,12 @@ def main(initialise_git_repository: str, deploy_docs_to_github_pages: str) -> in
print(
"You now have a local git repository. To sync this to GitHub "
"you need to create an empty GitHub repo with the name "
"{{cookiecutter.github_username}}/{{cookiecutter.project_slug}} "
"{{cookiecutter.__repo_name}} "
"- DO NOT SELECT ANY OTHER OPTION.\n\nSee this link for more detail "
"https://docs.github.com/en/get-started/quickstart/create-a-repo.\n\n"
"Then run:\n\n"
"git remote add origin [email protected]:"
"{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}.git\n"
"{{cookiecutter.__repo_name}}.git\n"
)
except subprocess.CalledProcessError as e:
# some other error
Expand All @@ -91,13 +91,11 @@ def main(initialise_git_repository: str, deploy_docs_to_github_pages: str) -> in
"deploying as a GitHub Pages website. To allow the GitHub Actions bot to "
"push to the gh-pages branch you need to enable 'Read and write "
"permissions' under 'Workflow permissions' at\n\n"
"https://github.com/{{cookiecutter.github_username}}/"
"{{cookiecutter.project_slug}}/settings/actions\n\n"
"{{cookiecutter.__repo_url}}/settings/actions\n\n"
"After the 'Documentation' workflow has successfully completed at least "
"once you will also need to configure the repository to deploy a GitHub "
"pages site from the content on the gh-pages branch by going to\n\n"
"https://github.com/{{cookiecutter.github_username}}/"
"{{cookiecutter.project_slug}}/settings/pages\n\n"
"{{cookiecutter.__repo_url}}/settings/pages\n\n"
"and under 'Built and deployment' selecting 'Deploy from a branch' for "
"the 'Source' drop-down and 'gh-pages' for the 'Branch' drop-down, "
"leaving the branch path drop-down with its default value of '/ (root)'."
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def project_config() -> dict:

"""
return {
"github_username": "test-user",
"github_owner": "test-user",
"project_short_description": "description",
"project_name": "Cookiecutter Test",
"expected_repo_name": "cookiecutter-test",
Expand Down
8 changes: 4 additions & 4 deletions tests/test_git_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_initialisation_of_git_repo(
"--no-input",
"--output-dir",
f"{tmp_path}",
f"github_username={project_config['github_username']}",
f"github_owner={project_config['github_owner']}",
f"project_name={project_config['project_name']}",
f"project_short_description={project_config['project_short_description']}",
git_init_cookiecutter_option,
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_initialisation_of_git_repo(
)
assert (
"GitHub CLI detected, you can create a repo with the following:\n\n"
f"gh repo create {project_config['github_username']}/"
f"gh repo create {project_config['github_owner']}/"
f"{project_config['expected_repo_name']} -d "
f"'{project_config['project_short_description']}' --public -r "
f"origin --source {project_config['expected_repo_name']}"
Expand All @@ -88,12 +88,12 @@ def test_initialisation_of_git_repo(
assert (
"You now have a local git repository. To sync this to GitHub you "
"need to create an empty GitHub repo with the name "
f"{project_config['github_username']}/"
f"{project_config['github_owner']}/"
f"{project_config['expected_repo_name']} - DO NOT SELECT ANY "
"OTHER OPTION.\n\nSee this link for more detail "
"https://docs.github.com/en/get-started/quickstart/create-a-repo"
".\n\nThen run:\n\ngit remote add origin [email protected]:"
f"{project_config['github_username']}/"
f"{project_config['github_owner']}/"
f"{project_config['expected_repo_name']}.git" in cookie.stdout
)
else:
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ authors:
- family-names: "{{cookiecutter.author_family_names }}"
given-names: "{{ cookiecutter.author_given_names }}"
email: "{{ cookiecutter.author_email }}"
repository-code: "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}"
repository-code: "{{ cookiecutter.__repo_url }}"
title: "{{ cookiecutter.project_name }}: {{ cookiecutter.project_short_description }}"
license: "{{ cookiecutter.license }}"
16 changes: 8 additions & 8 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
-->

<!-- prettier-ignore-start -->
[tests-badge]: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/actions/workflows/tests.yml/badge.svg
[tests-link]: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/actions/workflows/tests.yml
[linting-badge]: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/actions/workflows/linting.yml/badge.svg
[linting-link]: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/actions/workflows/linting.yml
[documentation-badge]: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/actions/workflows/docs.yml/badge.svg
[documentation-link]: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/actions/workflows/docs.yml
[tests-badge]: {{cookiecutter.__repo_url}}/actions/workflows/tests.yml/badge.svg
[tests-link]: {{cookiecutter.__repo_url}}/actions/workflows/tests.yml
[linting-badge]: {{cookiecutter.__repo_url}}/actions/workflows/linting.yml/badge.svg
[linting-link]: {{cookiecutter.__repo_url}}/actions/workflows/linting.yml
[documentation-badge]: {{cookiecutter.__repo_url}}/actions/workflows/docs.yml/badge.svg
[documentation-link]: {{cookiecutter.__repo_url}}/actions/workflows/docs.yml
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/{{cookiecutter.project_slug}}
[conda-link]: https://github.com/conda-forge/{{cookiecutter.project_slug}}-feedstock
[pypi-link]: https://pypi.org/project/{{cookiecutter.project_slug}}/
Expand Down Expand Up @@ -79,13 +79,13 @@ development version of `{{cookiecutter.project_slug}}` using `pip` in the curren
environment run

```sh
pip install git+https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}.git
pip install git+{{cookiecutter.__repo_url}}.git
```

Alternatively create a local clone of the repository with

```sh
git clone https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}.git
git clone {{cookiecutter.__repo_url}}.git
```

and then install in editable mode by running
Expand Down
6 changes: 3 additions & 3 deletions {{cookiecutter.project_slug}}/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ site_name: "{{cookiecutter.project_name}}"
site_description: "Documentation website for {{cookiecutter.project_name}}"
site_author: "{{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}}"
copyright: "Copyright © {% now 'utc', '%Y' %} {{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}}"
repo_url: "https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/"
repo_name: "{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}"
repo_url: "{{cookiecutter.__repo_url}}/"
repo_name: "{{cookiecutter.__repo_name}}"
edit_uri: edit/main/docs/

validation:
Expand Down Expand Up @@ -60,4 +60,4 @@ plugins:
extra:
social:
- icon: fontawesome/brands/github
link: "https://github.com/{{cookiecutter.github_username}}"
link: "https://github.com/{{cookiecutter.github_owner}}"
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ optional-dependencies = {dev = [
readme = "README.md"
requires-python = ">={{cookiecutter.min_python_version}}"
license.file = "LICENSE.md"
urls.homepage = "https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}"
urls.homepage = "{{cookiecutter.__repo_url}}"

[tool.coverage]
report = {sort = "cover"}
Expand Down