Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl disable details #436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,15 @@ comment:
hideFooterLink: true
```

### `comment.disableDetails:`

Disable details tag for report.

``` yaml
comment:
disableDetails: true
```

### `comment.deletePrevious:`

Delete previous code metrics report comments instead of hiding them
Expand Down Expand Up @@ -609,6 +618,15 @@ summary:
hideFooterLink: true
```

### `summary.disableDetails:`

Disable details tag for report.

``` yaml
comment:
disableDetails: true
```

### `summary.if:`

Conditions for adding report to job summary page.
Expand All @@ -634,6 +652,15 @@ body:
hideFooterLink: true
```

### `body.disableDetails:`

Disable details tag for report.

``` yaml
comment:
disableDetails: true
```

### `body.if:`

Conditions for inserting report body of pull request.
Expand Down
4 changes: 2 additions & 2 deletions cmd/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func commentReport(ctx context.Context, c *config.Config, content, key string) e
return nil
}

func createReportContent(ctx context.Context, c *config.Config, r, rPrev *report.Report, hideFooterLink bool) (string, error) {
func createReportContent(ctx context.Context, c *config.Config, r, rPrev *report.Report, hideFooterLink bool, disableDetails bool) (string, error) {
repo, err := gh.Parse(c.Repository)
if err != nil {
return "", err
Expand Down Expand Up @@ -68,7 +68,7 @@ func createReportContent(ctx context.Context, c *config.Config, r, rPrev *report
)
if rPrev != nil {
d := r.Compare(rPrev)
table = d.Table()
table = d.Table(disableDetails)
fileTable = d.FileCoveragesTable(files)
for _, s := range d.CustomMetrics {
customTables = append(customTables, s.Table(), s.MetadataTable())
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ var rootCmd = &cobra.Command{
if err := c.DiffConfigReady(); err != nil {
cmd.PrintErrf("Skip comparing reports: %v\n", err)
}
content, err := createReportContent(ctx, c, r, rPrev, c.Comment.HideFooterLink)
content, err := createReportContent(ctx, c, r, rPrev, c.Comment.HideFooterLink, c.Comment.DisableDetails)
if err != nil {
return err
}
Expand All @@ -403,7 +403,7 @@ var rootCmd = &cobra.Command{
if err := c.DiffConfigReady(); err != nil {
cmd.PrintErrf("Skip comparing reports: %v\n", err)
}
content, err := createReportContent(ctx, c, r, rPrev, c.Summary.HideFooterLink)
content, err := createReportContent(ctx, c, r, rPrev, c.Summary.HideFooterLink, c.Summary.DisableDetails)
if err != nil {
return err
}
Expand All @@ -428,7 +428,7 @@ var rootCmd = &cobra.Command{
if err := c.DiffConfigReady(); err != nil {
cmd.PrintErrf("Skip comparing reports: %v\n", err)
}
content, err := createReportContent(ctx, c, r, rPrev, c.Body.HideFooterLink)
content, err := createReportContent(ctx, c, r, rPrev, c.Body.HideFooterLink, c.Body.DisableDetails)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,20 @@ type Push struct {

type Comment struct {
HideFooterLink bool `yaml:"hideFooterLink"`
DisableDetails bool `yaml:"disableDetails"`
DeletePrevious bool `yaml:"deletePrevious"`
If string `yaml:"if,omitempty"`
}

type Summary struct {
HideFooterLink bool `yaml:"hideFooterLink"`
DisableDetails bool `yaml:"disableDetails"`
If string `yaml:"if,omitempty"`
}

type Body struct {
HideFooterLink bool `yaml:"hideFooterLink"`
DisableDetails bool `yaml:"disableDetails"`
If string `yaml:"if,omitempty"`
}

Expand Down
8 changes: 6 additions & 2 deletions report/diff_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (d *DiffReport) Out(w io.Writer) {

var leftSepRe = regexp.MustCompile(`(?m)^\|`)

func (d *DiffReport) Table() string {
func (d *DiffReport) Table(disableDetails bool) string {
var out []string

// Markdown table
Expand Down Expand Up @@ -120,7 +120,11 @@ func (d *DiffReport) Table() string {
t2 = strings.Replace(t2, " | Test Execution", "+ | Test Execution", 1)
}
}
out = append(out, fmt.Sprintf("<details>\n\n<summary>Details</summary>\n\n``` diff\n%s```\n\n</details>\n", t2))
if disableDetails {
out = append(out, fmt.Sprintf("``` diff\n%s```\n", t2))
} else {
out = append(out, fmt.Sprintf("<details>\n\n<summary>Details</summary>\n\n``` diff\n%s```\n\n</details>\n", t2))
}

return strings.Join(out, "\n")
}
Expand Down
Loading