diff --git a/cookiecutter.json b/cookiecutter.json index 0ec46ab9..d36c2d33 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -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}}", + "__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", @@ -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", diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 6bf3b0c2..0d0f8a71 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -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 " @@ -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 git@github.com:" - "{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}.git\n" + "{{cookiecutter.__repo_name}}.git\n" ) except subprocess.CalledProcessError as e: # some other error @@ -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)'." diff --git a/tests/conftest.py b/tests/conftest.py index f021ce5b..1549178e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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", diff --git a/tests/test_git_init.py b/tests/test_git_init.py index 835b99ac..4c42839a 100644 --- a/tests/test_git_init.py +++ b/tests/test_git_init.py @@ -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, @@ -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']}" @@ -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 git@github.com:" - f"{project_config['github_username']}/" + f"{project_config['github_owner']}/" f"{project_config['expected_repo_name']}.git" in cookie.stdout ) else: diff --git a/{{cookiecutter.project_slug}}/CITATION.cff b/{{cookiecutter.project_slug}}/CITATION.cff index 264ea034..1f2d7a4c 100644 --- a/{{cookiecutter.project_slug}}/CITATION.cff +++ b/{{cookiecutter.project_slug}}/CITATION.cff @@ -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 }}" diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index a14c710f..0a2fb1ff 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -13,12 +13,12 @@ --> -[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}}/ @@ -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 diff --git a/{{cookiecutter.project_slug}}/mkdocs.yml b/{{cookiecutter.project_slug}}/mkdocs.yml index 34ef17e7..d64d7da4 100644 --- a/{{cookiecutter.project_slug}}/mkdocs.yml +++ b/{{cookiecutter.project_slug}}/mkdocs.yml @@ -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: @@ -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}}" diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 30bea4d6..3416d848 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -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"}