diff --git a/internal/glance/templates/repository.html b/internal/glance/templates/repository.html
index d0d1b8e2..0dbe9383 100644
--- a/internal/glance/templates/repository.html
+++ b/internal/glance/templates/repository.html
@@ -7,7 +7,7 @@
{{ .Repository.Forks | formatNumber }} forks
-{{ if gt (len .Repository.Commits) 0 }}
+{{ if .Repository.ShowCommits }}
Last {{ .CommitsLimit }} commits
@@ -15,6 +15,11 @@
{{ range .Repository.Commits }}
{{ end }}
+ {{ if .Repository.FixedHeight }}
+ {{ range .Repository.CommitsDiff }}
+
+ {{ end }}
+ {{ end }}
{{ range .Repository.Commits }}
@@ -24,7 +29,7 @@
{{ end }}
-{{ if gt (len .Repository.PullRequests) 0 }}
+{{ if .Repository.ShowPullRequests }}
Open pull requests ({{ .Repository.OpenPullRequests | formatNumber }} total)
@@ -32,6 +37,11 @@
{{ range .Repository.PullRequests }}
{{ end }}
+ {{ if .Repository.FixedHeight }}
+ {{ range .Repository.PullRequestsDiff }}
+
+ {{ end }}
+ {{ end }}
{{ range .Repository.PullRequests }}
@@ -41,7 +51,7 @@
{{ end }}
-{{ if gt (len .Repository.Issues) 0 }}
+{{ if .Repository.ShowIssues }}
Open issues ({{ .Repository.OpenIssues | formatNumber }} total)
@@ -49,6 +59,11 @@
{{ range .Repository.Issues }}
{{ end }}
+ {{ if .Repository.FixedHeight }}
+ {{ range .Repository.IssuesDiff }}
+
+ {{ end }}
+ {{ end }}
{{ range .Repository.Issues }}
diff --git a/internal/glance/widget-repository.go b/internal/glance/widget-repository.go
index 1eeb8b4b..62272e86 100644
--- a/internal/glance/widget-repository.go
+++ b/internal/glance/widget-repository.go
@@ -19,6 +19,7 @@ type repositoryWidget struct {
PullRequestsLimit int `yaml:"pull-requests-limit"`
IssuesLimit int `yaml:"issues-limit"`
CommitsLimit int `yaml:"commits-limit"`
+ FixedHeight bool `yaml:"fixed-height"`
Repository repository `yaml:"-"`
}
@@ -47,6 +48,7 @@ func (widget *repositoryWidget) update(ctx context.Context) {
widget.PullRequestsLimit,
widget.IssuesLimit,
widget.CommitsLimit,
+ widget.FixedHeight,
)
if !widget.canContinueUpdateAfterHandlingErr(err) {
@@ -70,6 +72,13 @@ type repository struct {
Issues []githubTicket
LastCommits int
Commits []githubCommitDetails
+ PullRequestsDiff int
+ IssuesDiff int
+ CommitsDiff int
+ ShowPullRequests bool
+ ShowIssues bool
+ ShowCommits bool
+ FixedHeight bool
}
type githubTicket struct {
@@ -111,7 +120,7 @@ type gitHubCommitResponseJson struct {
} `json:"commit"`
}
-func fetchRepositoryDetailsFromGithub(repo string, token string, maxPRs int, maxIssues int, maxCommits int) (repository, error) {
+func fetchRepositoryDetailsFromGithub(repo string, token string, maxPRs int, maxIssues int, maxCommits int, fixedHeight bool) (repository, error) {
repositoryRequest, err := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/repos/%s", repo), nil)
if err != nil {
return repository{}, fmt.Errorf("%w: could not create request with repository: %v", errNoContent, err)
@@ -176,12 +185,19 @@ func fetchRepositoryDetailsFromGithub(repo string, token string, maxPRs int, max
}
details := repository{
- Name: repositoryResponse.Name,
- Stars: repositoryResponse.Stars,
- Forks: repositoryResponse.Forks,
- PullRequests: make([]githubTicket, 0, len(PRsResponse.Tickets)),
- Issues: make([]githubTicket, 0, len(issuesResponse.Tickets)),
- Commits: make([]githubCommitDetails, 0, len(commitsResponse)),
+ Name: repositoryResponse.Name,
+ Stars: repositoryResponse.Stars,
+ Forks: repositoryResponse.Forks,
+ PullRequests: make([]githubTicket, 0, len(PRsResponse.Tickets)),
+ Issues: make([]githubTicket, 0, len(issuesResponse.Tickets)),
+ Commits: make([]githubCommitDetails, 0, len(commitsResponse)),
+ PullRequestsDiff: maxPRs - len(PRsResponse.Tickets),
+ IssuesDiff: maxIssues - len(issuesResponse.Tickets),
+ CommitsDiff: maxCommits - len(commitsResponse),
+ ShowPullRequests: fixedHeight || len(PRsResponse.Tickets) > 0,
+ ShowIssues: fixedHeight || len(issuesResponse.Tickets) > 0,
+ ShowCommits: fixedHeight || len(commitsResponse) > 0,
+ FixedHeight: fixedHeight,
}
err = nil