local_repo
This module contains functions used to set up a local git repository with ssb-project.
create_project_from_template(project_name, description, template_repo_url, checkout, working_directory, license_year=None, name=None, email=None, override_dir=None)
Creates a project from CookieCutter template.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
Name of project |
required |
description
|
str
|
Project description |
required |
license_year
|
Optional[str]
|
Year to be inserted into the LICENSE |
None
|
template_repo_url
|
str
|
The Cookiecutter template URI. |
required |
checkout
|
str | None
|
The git reference to check against. Supports branches, tags and commit hashes. |
required |
working_directory
|
Path
|
Working directory |
required |
name
|
Optional[str]
|
Optional name of project owner |
None
|
email
|
Optional[str]
|
Optional email of project owner |
None
|
override_dir
|
Optional[Path]
|
Used to hard set working_directory. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Path of project. |
Source code in ssb_project_cli/ssb_project/create/local_repo.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
extract_name_email()
Grabs email and name from git config.
Returns:
Name | Type | Description |
---|---|---|
name |
str
|
Value of user.name from git config element |
email |
str
|
Value of user.email from git config element |
Source code in ssb_project_cli/ssb_project/create/local_repo.py
84 85 86 87 88 89 90 91 92 93 |
|
get_gitconfig_element(element)
Grabs a property from git config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
str
|
Name of the git config element retrive |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Value of git config element |
Source code in ssb_project_cli/ssb_project/create/local_repo.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
make_and_init_git_repo(repo_dir)
Makes and pushes a GitHub repository.
Inits a local repository, adds all files and commits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_dir
|
Path
|
Path to local Repository |
required |
Returns:
Name | Type | Description |
---|---|---|
Repo |
Repo
|
Repository |
Source code in ssb_project_cli/ssb_project/create/local_repo.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
make_git_repo_and_push(github_token, github_url, repo_dir)
Makes and pushes a GitHub repository.
Inits a local repository and tries to push it to GitHub, for more information see TempGitRemote.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
github_token
|
str
|
GitHub personal access token |
required |
github_url
|
str
|
Repository url |
required |
repo_dir
|
Path
|
Path to local Repository |
required |
Source code in ssb_project_cli/ssb_project/create/local_repo.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
mangle_url(url, mangle_name)
Create url mangled with a string: credential or username.
Source code in ssb_project_cli/ssb_project/create/local_repo.py
154 155 156 157 158 |
|
reset_project_git_configuration(project_name, template_repo_url, checkout, project_directory)
Overrides .gitattributes and .gitignore inn a given project directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
Name of project. |
required |
template_repo_url
|
str
|
URL for the chosen template. |
required |
checkout
|
str | None
|
The git reference to check against. Supports branches, tags and commit hashes. |
required |
project_directory
|
Path
|
Directory of the project. |
required |
Source code in ssb_project_cli/ssb_project/create/local_repo.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|