git_env
GitEnv
¶
Bases: BaseModel
Object to store the git configuration.
Attributes:
Name | Type | Description |
---|---|---|
sha |
str
|
... |
branch |
str
|
... |
target_branch |
str
|
... |
commit |
Commit | None
|
... |
pull_request |
PullRequest | None
|
... |
release |
Release | None
|
... |
Source code in m/ci/git_env.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
get_build_tag(config, run_id)
¶
Create a build tag for the current commit.
It is tempting to use the config_version when creating a build tag for pull requests or branches. This will only be annoying when testing.
Consider the following scenario. An application is being tested with
1.0.1-pr99.b123
. When using docker you may want to refer to the
latest pr build by using 1.0.1-pr99
. Now lets say that a release
happened and now the config_version is at 1.1.0
. The application
build will not get the latest changes because the new changes are in
1.1.0-pr99
.
There are two solutions, either always state the version that is being used or make a tag to depend only on the pull request number. This is the reason why for prs (constantly changing) we avoid using the version in the configuration.
For release prs we use rc
followed by the pull request. In this case
it is safe to use config_version given that there should only be
one release at a time. We treat hotfixes similar to releases.
Git flow will generate a special build tag: SKIP. This will happen when we try to merge a release or hotfix branch to the develop branch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The |
required |
run_id |
str
|
A unique identifier for the run/job. |
required |
Returns:
Type | Description |
---|---|
Res[str]
|
A unique identifier for the build. This tag is compatible with |
Res[str]
|
both |
Source code in m/ci/git_env.py
get_pr_branch()
¶
get_pr_number()
¶
Get the pull request number or 0 if not a pull request.
Returns:
Type | Description |
---|---|
int
|
The pull request number or 0 if not a pull request. |
get_py_tag(config, run_id)
¶
Create a python tag for the current commit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The |
required |
run_id |
str
|
A unique identifier for the run/job. |
required |
Returns:
Type | Description |
---|---|
Res[str]
|
A unique identifier for the build. This tag is compatible with |
Res[str]
|
python. |
Source code in m/ci/git_env.py
is_hotfix_pr(config)
¶
Determine if the the current pr is a hotfix pr.
It is a release pr as far as the pull request should see it but from the context of the git environment we need to label it as a hotfix pr.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The m configuration object. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the we are dealing with hotfix pr. |
Source code in m/ci/git_env.py
is_release(config)
¶
Determine if the current commit should create a release.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The |
required |
Returns:
Type | Description |
---|---|
bool
|
True if we are dealing with a release. |
Source code in m/ci/git_env.py
is_release_pr(config)
¶
Determine if the the current pr is a release pr.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The |
required |
Returns:
Type | Description |
---|---|
bool
|
True if we are dealing with a release pr. |
Source code in m/ci/git_env.py
get_git_env(config, env_vars)
¶
Obtain the git environment by asking Github's API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The m configuration object. |
required |
env_vars |
EnvVars
|
The environment variables. |
required |
Returns:
Type | Description |
---|---|
Res[GitEnv]
|
The git environment object or an issue. |
Source code in m/ci/git_env.py
get_hotfix_prefix(config)
¶
Find out the hotfix prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The m configuration. Its workflow is used to determine the prefix. |
required |
Returns:
Type | Description |
---|---|
str | None
|
The hofix prefix or None if not using a supported workflow. |
Source code in m/ci/git_env.py
get_pr_number(branch)
¶
Retrieve the pull request number from the branch name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
branch |
str
|
The branch name from where the pr number is extracted.py |
required |
Returns:
Type | Description |
---|---|
int | None
|
The pr number if the branch is a pull request otherwise |
Source code in m/ci/git_env.py
get_release_prefix(config)
¶
Find out the release prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
The m configuration. Its workflow is used to determine the prefix. |
required |
Returns:
Type | Description |
---|---|
str | None
|
The release prefix or None if not using a supported workflow. |