Skip to content

Commit 3a00a5b

Browse files
committed
feat: adding '-b' | '--behalf' flag
1 parent 510edda commit 3a00a5b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

bin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ parser.add_argument('parameters', {metavar: 'parameters', type: String, nargs: '
4040
parser.add_argument('-v', '--version', { action: 'version', version });
4141
parser.add_argument('-t', '--access-token', {type: String, help: 'access token with API permissions'});
4242
parser.add_argument('-u', '--url', {type: String, help: 'git system base url (e.g. https://github.com)'})
43+
parser.add_argument('-b', '--behalf', {type: String, help: 'user on whose behalf to execute the action'})
4344
parser.add_argument('--verbose', {action: 'store_true', help: 'increased console output'})
4445
parser.add_argument('--branch', {metavar: 'branch', type: String, help: 'gitops branch to use'})
4546
parser.add_argument('--repo', {metavar: 'repo', type: String, help: 'gitops repo to use'})

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ required options:
1616
- access_token: access token with API permissions
1717
- repo: git repository to use
1818
- branch: branch to use in git repository. defaults to repo's default branch if not given
19+
- behalf: user to act on behalf of
1920
- applications_dir: directory where the applications are stored
2021
- values_file: file containing the value to patch
2122
- application: name of the application to patch
@@ -145,10 +146,18 @@ export async function patch(options) {
145146
);
146147
targetBranch = defaultBranch;
147148
}
149+
150+
let commitMessage = `Patched '${filePath}'`;
151+
if(options.behalf) {
152+
commitMessage = `[${options.behalf}] ${commitMessage}`;
153+
}
154+
if(options.message) {
155+
commitMessage = options.message;
156+
}
157+
148158
let commitObject = {
149159
branch: targetBranch,
150-
// TODO add original author to commit message
151-
commit_message: options.message || `Patched '${filePath}'`,
160+
commit_message: commitMessage,
152161
actions: [
153162
{
154163
action: "update",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gitops-cli",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "GitOps tooling for CLI and CI",
55
"main": "bin.js",
66
"type": "module",

0 commit comments

Comments
 (0)