Skip to content

Commit

Permalink
Fix order of config files and name of project exclusion list conf
Browse files Browse the repository at this point in the history
  • Loading branch information
L7R7 committed Jul 8, 2024
1 parent 5d945f9 commit 5b04e1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
31 changes: 23 additions & 8 deletions src/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ data Config = Config
configFiles :: Parser [Path Abs File]
configFiles =
sequenceA
[ runIO (getHomeDir >>= \home -> resolveFile home ".gitlab-helper.yml"),
runIO (resolveFile' ".gitlab-helper.yml")
[ runIO (resolveFile' ".gitlab-helper.yml"),
runIO (getHomeDir >>= \home -> resolveFile home ".gitlab-helper.yml")
]

instance HasParser Config where
Expand Down Expand Up @@ -81,7 +81,7 @@ instance HasParser Config where
reader (commaSeparatedList (Id <$> positiveIntReader)),
long "exclude-projects",
option,
conf "exclude-projects",
conf "excludeProjects",
env "EXCLUDE_PROJECTS",
metavar "ID1,ID2,ID3",
value []
Expand Down Expand Up @@ -194,11 +194,26 @@ data MergeRequestUpdateAction = List | Rebase | Merge MergeCiOption | SetToDraft
instance HasParser MergeRequestUpdateAction where
settingsParser =
commands
[ command "rebase" "rebase the merge requests" $ pure Rebase,
command "merge" "merge the merge requests" $ Merge <$> settingsParser,
command "draft" "set the merge requests to `draft`" $ pure SetToDraft,
command "ready" "mark the merge requests as ready" $ pure MarkAsReady,
command "list" "list the merge requests" $ pure List
[ command
"rebase"
"rebase the merge requests"
(pure Rebase),
command
"merge"
"merge the merge requests"
(Merge <$> settingsParser),
command
"draft"
"set the merge requests to `draft`"
(pure SetToDraft),
command
"ready"
"mark the merge requests as ready"
(pure MarkAsReady),
command
"list"
"list the merge requests"
(pure List)
]

data MergeCiOption = PipelineMustSucceed | SkipCi deriving stock (Show)
Expand Down
12 changes: 9 additions & 3 deletions test_resources/reference.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Usage: gitlab-helper --group-id GROUP_ID --base-url URL --api-token TOKEN --exclude-projects ID1,ID2,ID3 show-branches | show-projects | list-all-projects-meta | list-projects-meta | enable-source-branch-deletion --execute|-x | enable-all-discussions-must-be-resolved-for-merge-requirement --execute|-x | enable-successful-pipeline-for-merge-requirement --execute|-x | show-schedules | show-merge-requests --[no-]recheck-merge-status | count-deployments --year YEAR --[no-]include-archived-projects | set-merge-method-to-fast-forward --execute|-x | update-merge-requests rebase | merge --skip-ci | draft | ready | list -u|--user-id USER_ID (--search-title TXT) | (-s|--search TXT) --[no-]recheck-merge-status --execute|-x
Usage: gitlab-helper --config-file FILE_PATH --group-id GROUP_ID --base-url URL --api-token TOKEN --exclude-projects ID1,ID2,ID3 show-branches | show-projects | list-all-projects-meta | list-projects-meta | enable-source-branch-deletion --execute|-x | enable-all-discussions-must-be-resolved-for-merge-requirement --execute|-x | enable-successful-pipeline-for-merge-requirement --execute|-x | show-schedules | show-merge-requests --[no-]recheck-merge-status | count-deployments --year YEAR --[no-]include-archived-projects | set-merge-method-to-fast-forward --execute|-x | update-merge-requests rebase | merge --skip-ci | draft | ready | list -u|--user-id USER_ID (--search-title TXT) | (-s|--search TXT) --[no-]recheck-merge-status --execute|-x

All settings:
Path to the configuration file
option: --config-file FILE_PATH
env: CONFIG_FILE FILE_PATH

ID of the GitLab group to work with
option: --group-id GROUP_ID
env: GLH_GROUP_ID GROUP_ID
Expand All @@ -26,7 +30,7 @@
option: --exclude-projects ID1,ID2,ID3
env: GLH_EXCLUDE_PROJECTS ID1,ID2,ID3
config:
config.exclude-projects: # or null
config.excludeProjects: # or null
- <number> # 64 bit signed integer

Show branches
Expand Down Expand Up @@ -121,6 +125,7 @@


Options:
--config-file Path to the configuration file
--group-id ID of the GitLab group to work with
--base-url Base URL of your GitLab instance (e.g. `https://my.gitlab.com`)
--api-token API Token to use for authorizing requests against the Gitlab API. `api` scope is required.
Expand Down Expand Up @@ -157,6 +162,7 @@
--execute|-x whether to actually change the world via the API. By default, only a dry run will be performed default: DryRun

Environment Variables:
CONFIG_FILE FILE_PATH Path to the configuration file
GLH_GROUP_ID GROUP_ID ID of the GitLab group to work with
GLH_BASE_URL URL Base URL of your GitLab instance (e.g. `https://my.gitlab.com`)
GLH_API_TOKEN TOKEN API Token to use for authorizing requests against the Gitlab API. `api` scope is required.
Expand All @@ -176,7 +182,7 @@
# or null
<string>
set the list of projects to exclude as a comma-separated list of IDs
config.exclude-projects:
config.excludeProjects:
# or null
- <number> # 64 bit signed integer

0 comments on commit 5b04e1c

Please sign in to comment.