Skip to content

Commit d61deda

Browse files
feat: Expose git author parameters
Add optional git author parameters to all commands creating git commits. If no author is provided the git user and email will be used for both committer and author. Example: ```bash gitopscli deploy \ --git-user "GitOps CLI" \ --git-email "[email protected]" \ --git-author-name "John Doe" \ --git-author-email "[email protected]" \ ... ``` Resolves #195
1 parent 70c69fc commit d61deda

22 files changed

+460
-85
lines changed

docs/commands/create-pr-preview.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ gitopscli create-pr-preview \
2222

2323
## Usage
2424
```
25-
usage: gitopscli create-pr-preview [-h] --username USERNAME --password PASSWORD
26-
[--git-user GIT_USER] [--git-email GIT_EMAIL]
27-
--organisation ORGANISATION --repository-name
28-
REPOSITORY_NAME [--git-provider GIT_PROVIDER]
29-
[--git-provider-url GIT_PROVIDER_URL]
30-
--pr-id PR_ID
31-
[--parent-id PARENT_ID] [-v [VERBOSE]]
25+
usage: gitopscli create-pr-preview [-h] --username USERNAME --password
26+
PASSWORD [--git-user GIT_USER]
27+
[--git-email GIT_EMAIL]
28+
[--git-author-name GIT_AUTHOR_NAME]
29+
[--git-author-email GIT_AUTHOR_EMAIL]
30+
--organisation ORGANISATION
31+
--repository-name REPOSITORY_NAME
32+
[--git-provider GIT_PROVIDER]
33+
[--git-provider-url GIT_PROVIDER_URL]
34+
--pr-id PR_ID [--parent-id PARENT_ID]
35+
[-v [VERBOSE]]
3236
3337
options:
3438
-h, --help show this help message and exit
@@ -39,6 +43,10 @@ options:
3943
--git-user GIT_USER Git Username
4044
--git-email GIT_EMAIL
4145
Git User Email
46+
--git-author-name GIT_AUTHOR_NAME
47+
Git Author Name
48+
--git-author-email GIT_AUTHOR_EMAIL
49+
Git Author Email
4250
--organisation ORGANISATION
4351
Apps Git organisation/projectKey
4452
--repository-name REPOSITORY_NAME

docs/commands/create-preview.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ gitopscli create-preview \
3636
```
3737
usage: gitopscli create-preview [-h] --username USERNAME --password PASSWORD
3838
[--git-user GIT_USER] [--git-email GIT_EMAIL]
39+
[--git-author-name GIT_AUTHOR_NAME]
40+
[--git-author-email GIT_AUTHOR_EMAIL]
3941
--organisation ORGANISATION --repository-name
4042
REPOSITORY_NAME [--git-provider GIT_PROVIDER]
4143
[--git-provider-url GIT_PROVIDER_URL]
42-
--preview-id PREVIEW_ID
44+
--git-hash GIT_HASH --preview-id PREVIEW_ID
4345
[-v [VERBOSE]]
4446
4547
options:
@@ -51,6 +53,10 @@ options:
5153
--git-user GIT_USER Git Username
5254
--git-email GIT_EMAIL
5355
Git User Email
56+
--git-author-name GIT_AUTHOR_NAME
57+
Git Author Name
58+
--git-author-email GIT_AUTHOR_EMAIL
59+
Git Author Email
5460
--organisation ORGANISATION
5561
Apps Git organisation/projectKey
5662
--repository-name REPOSITORY_NAME

docs/commands/delete-pr-preview.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ gitopscli delete-pr-preview \
2020
```
2121
usage: gitopscli delete-pr-preview [-h] --username USERNAME --password
2222
PASSWORD [--git-user GIT_USER]
23-
[--git-email GIT_EMAIL] --organisation
24-
ORGANISATION --repository-name
25-
REPOSITORY_NAME
23+
[--git-email GIT_EMAIL]
24+
[--git-author-name GIT_AUTHOR_NAME]
25+
[--git-author-email GIT_AUTHOR_EMAIL]
26+
--organisation ORGANISATION
27+
--repository-name REPOSITORY_NAME
2628
[--git-provider GIT_PROVIDER]
2729
[--git-provider-url GIT_PROVIDER_URL]
2830
--branch BRANCH
@@ -38,6 +40,10 @@ options:
3840
--git-user GIT_USER Git Username
3941
--git-email GIT_EMAIL
4042
Git User Email
43+
--git-author-name GIT_AUTHOR_NAME
44+
Git Author Name
45+
--git-author-email GIT_AUTHOR_EMAIL
46+
Git Author Email
4147
--organisation ORGANISATION
4248
Apps Git organisation/projectKey
4349
--repository-name REPOSITORY_NAME

docs/commands/delete-preview.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ gitopscli delete-preview \
2020
```
2121
usage: gitopscli delete-preview [-h] --username USERNAME --password PASSWORD
2222
[--git-user GIT_USER] [--git-email GIT_EMAIL]
23+
[--git-author-name GIT_AUTHOR_NAME]
24+
[--git-author-email GIT_AUTHOR_EMAIL]
2325
--organisation ORGANISATION --repository-name
2426
REPOSITORY_NAME [--git-provider GIT_PROVIDER]
2527
[--git-provider-url GIT_PROVIDER_URL]
@@ -36,6 +38,10 @@ options:
3638
--git-user GIT_USER Git Username
3739
--git-email GIT_EMAIL
3840
Git User Email
41+
--git-author-name GIT_AUTHOR_NAME
42+
Git Author Name
43+
--git-author-email GIT_AUTHOR_EMAIL
44+
Git Author Email
3945
--organisation ORGANISATION
4046
Apps Git organisation/projectKey
4147
--repository-name REPOSITORY_NAME

docs/commands/deploy.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,37 @@ usage: gitopscli deploy [-h] --file FILE --values VALUES
125125
[--single-commit [SINGLE_COMMIT]]
126126
[--commit-message COMMIT_MESSAGE] --username USERNAME
127127
--password PASSWORD [--git-user GIT_USER]
128-
[--git-email GIT_EMAIL] --organisation ORGANISATION
129-
--repository-name REPOSITORY_NAME
130-
[--git-provider GIT_PROVIDER]
128+
[--git-email GIT_EMAIL]
129+
[--git-author-name GIT_AUTHOR_NAME]
130+
[--git-author-email GIT_AUTHOR_EMAIL]
131+
--organisation ORGANISATION --repository-name
132+
REPOSITORY_NAME [--git-provider GIT_PROVIDER]
131133
[--git-provider-url GIT_PROVIDER_URL]
132134
[--create-pr [CREATE_PR]] [--auto-merge [AUTO_MERGE]]
133-
[--merge-method MERGE_METHOD] [-v [VERBOSE]]
135+
[--merge-method MERGE_METHOD] [--json [JSON]]
136+
[--pr-labels PR_LABELS]
137+
[--merge-parameters MERGE_PARAMETERS] [-v [VERBOSE]]
134138

135139
options:
136140
-h, --help show this help message and exit
137141
--file FILE YAML file path
138-
--values VALUES YAML/JSON object with the YAML path as key and the desired value as value
142+
--values VALUES YAML/JSON object with the YAML path as key and the
143+
desired value as value
139144
--single-commit [SINGLE_COMMIT]
140145
Create only single commit for all updates
141146
--commit-message COMMIT_MESSAGE
142147
Specify exact commit message of deployment commit
143-
--username USERNAME Git username (alternative: GITOPSCLI_USERNAME env variable)
144-
--password PASSWORD Git password or token (alternative: GITOPSCLI_PASSWORD env variable)
148+
--username USERNAME Git username (alternative: GITOPSCLI_USERNAME env
149+
variable)
150+
--password PASSWORD Git password or token (alternative: GITOPSCLI_PASSWORD
151+
env variable)
145152
--git-user GIT_USER Git Username
146153
--git-email GIT_EMAIL
147154
Git User Email
155+
--git-author-name GIT_AUTHOR_NAME
156+
Git Author Name
157+
--git-author-email GIT_AUTHOR_EMAIL
158+
Git Author Email
148159
--organisation ORGANISATION
149160
Apps Git organisation/projectKey
150161
--repository-name REPOSITORY_NAME

docs/commands/sync-apps.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ gitopscli sync-apps \
101101
```
102102
usage: gitopscli sync-apps [-h] --username USERNAME --password PASSWORD
103103
[--git-user GIT_USER] [--git-email GIT_EMAIL]
104+
[--git-author-name GIT_AUTHOR_NAME]
105+
[--git-author-email GIT_AUTHOR_EMAIL]
104106
--organisation ORGANISATION --repository-name
105107
REPOSITORY_NAME [--git-provider GIT_PROVIDER]
106108
[--git-provider-url GIT_PROVIDER_URL]
@@ -117,6 +119,10 @@ options:
117119
--git-user GIT_USER Git Username
118120
--git-email GIT_EMAIL
119121
Git User Email
122+
--git-author-name GIT_AUTHOR_NAME
123+
Git Author Name
124+
--git-author-email GIT_AUTHOR_EMAIL
125+
Git Author Email
120126
--organisation ORGANISATION
121127
Apps Git organisation/projectKey
122128
--repository-name REPOSITORY_NAME

gitopscli/cliparser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ def __add_git_credentials_args(deploy_p: ArgumentParser) -> None:
219219
def __add_git_commit_user_args(deploy_p: ArgumentParser) -> None:
220220
deploy_p.add_argument("--git-user", help="Git Username", default="GitOpsCLI")
221221
deploy_p.add_argument("--git-email", help="Git User Email", default="[email protected]")
222+
deploy_p.add_argument("--git-author-name", help="Git Author Name")
223+
deploy_p.add_argument("--git-author-email", help="Git Author Email")
222224

223225

224226
def __add_git_org_and_repo_args(deploy_p: ArgumentParser) -> None:

gitopscli/commands/create_pr_preview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class Args(GitApiConfig):
1111
git_user: str
1212
git_email: str
1313

14+
git_author_name: Optional[str]
15+
git_author_email: Optional[str]
16+
1417
organisation: str
1518
repository_name: str
1619

@@ -37,6 +40,8 @@ def execute(self) -> None:
3740
password=args.password,
3841
git_user=args.git_user,
3942
git_email=args.git_email,
43+
git_author_name=args.git_author_name,
44+
git_author_email=args.git_author_email,
4045
organisation=args.organisation,
4146
repository_name=args.repository_name,
4247
git_provider=args.git_provider,

gitopscli/commands/create_preview.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import shutil
44
from dataclasses import dataclass
5-
from typing import Any, Callable
5+
from typing import Any, Callable, Optional
66
from gitopscli.git_api import GitApiConfig, GitRepo, GitRepoApi, GitRepoApiFactory
77
from gitopscli.io_api.yaml_util import update_yaml_file, YAMLException, yaml_file_dump
88
from gitopscli.gitops_config import GitOpsConfig
@@ -17,6 +17,9 @@ class Args(GitApiConfig):
1717
git_user: str
1818
git_email: str
1919

20+
git_author_name: Optional[str]
21+
git_author_email: Optional[str]
22+
2023
organisation: str
2124
repository_name: str
2225

@@ -82,7 +85,13 @@ def execute(self) -> None:
8285
self.__deployment_updated_callback(gitops_config.get_updated_message(context))
8386

8487
def __commit_and_push(self, git_repo: GitRepo, message: str) -> None:
85-
git_repo.commit(self.__args.git_user, self.__args.git_email, message)
88+
git_repo.commit(
89+
self.__args.git_user,
90+
self.__args.git_email,
91+
self.__args.git_author_name,
92+
self.__args.git_author_email,
93+
message,
94+
)
8695
git_repo.push()
8796

8897
def __get_gitops_config(self) -> GitOpsConfig:

gitopscli/commands/delete_pr_preview.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from typing import Optional
23
from gitopscli.git_api import GitApiConfig
34
from .delete_preview import DeletePreviewCommand
45
from .command import Command
@@ -10,6 +11,9 @@ class Args(GitApiConfig):
1011
git_user: str
1112
git_email: str
1213

14+
git_author_name: Optional[str]
15+
git_author_email: Optional[str]
16+
1317
organisation: str
1418
repository_name: str
1519

@@ -27,6 +31,8 @@ def execute(self) -> None:
2731
password=args.password,
2832
git_user=args.git_user,
2933
git_email=args.git_email,
34+
git_author_name=args.git_author_name,
35+
git_author_email=args.git_author_email,
3036
organisation=args.organisation,
3137
repository_name=args.repository_name,
3238
git_provider=args.git_provider,

0 commit comments

Comments
 (0)