Skip to content

Commit

Permalink
show: Add "comments" config option.
Browse files Browse the repository at this point in the history
I'd like to always display the full comments when viewing an MR or Issue.
Add a "comments" config variable that sets the "--comments" flag on
'mr show' and 'issue show'.

Add a "comments" local config option for the show commmands.

Additional fix: Fix a leftover HCL to TOML change in the README

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
  • Loading branch information
prarit committed Sep 6, 2020
1 parent dbf3165 commit 4104b40
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ instance. There are several ways to provide this information to `lab`:
2. environment variables: `CI_PROJECT_URL`, `CI_JOB_TOKEN`;
- Note: these are meant for when `lab` is running within a GitLab CI pipeline
3. directory-specific configuration file in [Tom's Obvious, Minimal Language (TOML)](https://github.com/toml-lang/toml): `./lab.toml`;
4. user-specific configuration file in HCL: `~/.config/lab/lab.toml`.
4. user-specific configuration file in TOML: `~/.config/lab/lab.toml`.

These are checked in order. If no suitable config values are found, `lab` will
prompt for your GitLab information and save it into `~/.config/lab/lab.toml`.
Expand All @@ -99,6 +99,13 @@ For example:
$ lab
Enter default GitLab host (default: https://gitlab.com):
Enter default GitLab token:
```

Additionally, there are command-specific configuration files in TOML: .git/lab/[command]-metadata.toml which provide users the ability to override some command line options:

```
comments = true # sets --comments on 'mr show' commands
```
# Completions

Expand Down
3 changes: 3 additions & 0 deletions cmd/issue_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ var issueShowCmd = &cobra.Command{
printIssue(issue, rn, renderMarkdown)

showComments, _ := cmd.Flags().GetBool("comments")
if showComments == false {
showComments = viper.GetBool("comments")
}
if showComments {
discussions, err := lab.IssueListDiscussions(rn, int(issueNum))
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/mr_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ var mrShowCmd = &cobra.Command{
}

showComments, _ := cmd.Flags().GetBool("comments")
if showComments == false {
showComments = viper.GetBool("comments")
}
if showComments {
discussions, err := lab.MRListDiscussions(rn, int(mrNum))
if err != nil {
Expand Down

0 comments on commit 4104b40

Please sign in to comment.