-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renaming
github_username
to github_owner
+ generating `__repo_nam…
…e` & `__repo_url` (#409) Though its not exposed to user now we have longer prompts rather than using variable names directly, I think `github_username` is a bit of a misnomer given that it can be either a user or organization name, hence I think `github_owner` would be a better choice. We also currently manually construct the GitHub repository URL in lots of different bits of the template and also the qualified repository name in a few places. We can use [double underscore prefixed (rendered) private variables](https://cookiecutter.readthedocs.io/en/stable/advanced/private_variables.html) in the cookiecutter config to generate the repository URL and qualified name once and then reuse elsewhere to avoid the repetition. This would also make it simpler to later switch to supporting alternative repository hosting options such as GitLab in future (which is the rational for naming the variables `__repo_name` and `__repo_url` rather than `__github_repo_name` and `__github_repo_url`). --------- Co-authored-by: Patrick J. Roddy <[email protected]> Co-authored-by: David Stansby <[email protected]>
- Loading branch information
1 parent
d5b41c7
commit 85b0b29
Showing
9 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [email protected]:" | ||
"{{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)'." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ def test_initialisation_of_git_repo( | |
) -> None: | ||
"""Checks to see if git was correctly initialised if desired.""" | ||
test_config = { | ||
"github_username": "test-user", | ||
"github_owner": "test-user", | ||
"project_short_description": "description", | ||
"project_name": "Cookiecutter Test", | ||
"initialise_git_repository": initialise_git_repository, | ||
|
@@ -57,7 +57,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 {test_config['github_username']}/" | ||
f"gh repo create {test_config['github_owner']}/" | ||
f"cookiecutter-test -d " | ||
f"\"{test_config['project_short_description']}\" --public -r " | ||
f"origin --source cookiecutter-test" in result.stdout | ||
|
@@ -69,11 +69,11 @@ 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"{test_config['github_username']}/" | ||
f"{test_config['github_owner']}/" | ||
f"cookiecutter-test - 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"{test_config['github_username']}/" | ||
f"{test_config['github_owner']}/" | ||
f"cookiecutter-test.git" in result.stdout | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters