forked from pybamm-team/pybamm-cookie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Git Initialisation Hooks (pybamm-team#32)
+ Added `git` initialisation hooks in the template to automatically initialise a `git repository` when a `generated project` is created by `cookiecutter`. + Added a default `main` branch parameter for git repository initialisation. Subtask - pybamm-team#26
- Loading branch information
1 parent
b6ea4f1
commit db24f92
Showing
2 changed files
with
27 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
], | ||
"org": "pybamm-team", | ||
"url": "https://{{ cookiecutter.platform }}.com/{{ cookiecutter.org }}/{{ cookiecutter.project_name }}", | ||
"branch": "main", | ||
"full_name": "John Doe", | ||
"email": "[email protected]", | ||
"project_short_description": "A template for creating battery modeling projects based on PyBaMM", | ||
|
@@ -31,7 +32,8 @@ | |
"gitlab": "GitLab" | ||
}, | ||
"org": "The name of your organisation (or username, if you are not part of an organisation)", | ||
"url": "The URL to your repository", | ||
"url": "The Origin URL to your repository", | ||
"branch": "The default branch of your repository", | ||
"full_name": "Your name", | ||
"email": "Your email", | ||
"project_short_description": "A short description of your project", | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import subprocess | ||
|
||
from pathlib import Path | ||
|
||
def prepare_git() -> None: | ||
|
||
git_author_name = "{{cookiecutter.full_name}}" | ||
git_author_email = "{{cookiecutter.email}}" | ||
git_branch = "{{cookiecutter.branch}}" | ||
|
||
# Initialise git | ||
subprocess.call( | ||
["git", "init", "-b", git_branch] | ||
) | ||
subprocess.call( | ||
["git", "config", "user.name", git_author_name] | ||
) | ||
subprocess.call( | ||
["git", "config", "user.email", git_author_email] | ||
) | ||
|
||
if __name__ == "__main__": | ||
print("Executing script!!") | ||
prepare_git() |