feat(repo): #54 enrich repo list and add move command#57
Conversation
repo list --details fetches last commit date and open PR count concurrently for each repo. repo move relocates a repo to a different project with an optional name prefix (e.g. --prefix "Archived-").
There was a problem hiding this comment.
Code Review
This pull request adds a bb repo move command and a --details flag for bb repo list to show commit dates and PR counts. It also introduces an api.Count helper. Feedback notes that the Visibility column is missing from the detailed view, the --details flag is not reflected in JSON output, and documentation was added for an unimplemented bb workspace members command.
| headers := []string{"Name", "Project", "Slug", "Language", "Last Commit", "Open PRs", "Updated"} | ||
| rows := make([][]string, len(repos)) | ||
| for i, r := range repos { | ||
| projectKey := "" | ||
| if r.Project != nil { | ||
| projectKey = r.Project.Key | ||
| } | ||
| lastCommit := "-" | ||
| if detailsMap[i].LastCommit != "" { | ||
| lastCommit = models.FormatTime(detailsMap[i].LastCommit) | ||
| } | ||
| rows[i] = []string{ | ||
| r.Name, | ||
| projectKey, | ||
| r.Slug, | ||
| r.Language, | ||
| lastCommit, | ||
| fmt.Sprintf("%d", detailsMap[i].OpenPRs), | ||
| models.FormatTime(r.UpdatedOn), | ||
| } | ||
| } |
There was a problem hiding this comment.
The Visibility column is missing in the detailed view, which creates an inconsistency with the default list view. It's recommended to include it to maintain a consistent user experience across both views.
headers := []string{"Name", "Project", "Slug", "Visibility", "Language", "Last Commit", "Open PRs", "Updated"}
rows := make([][]string, len(repos))
for i, r := range repos {
projectKey := ""
if r.Project != nil {
projectKey = r.Project.Key
}
lastCommit := "-"
if detailsMap[i].LastCommit != "" {
lastCommit = models.FormatTime(detailsMap[i].LastCommit)
}
rows[i] = []string{
r.Name,
projectKey,
r.Slug,
r.Visibility(),
r.Language,
lastCommit,
fmt.Sprintf("%d", detailsMap[i].OpenPRs),
models.FormatTime(r.UpdatedOn),
}
}| models.FormatTime(r.UpdatedOn), | ||
| } | ||
| } | ||
| return output.Format(format, repos, headers, rows) |
There was a problem hiding this comment.
When the --details flag is used with --format json, the output currently only contains the standard repository data. The extra details (last commit and open PR count) are not included in the JSON response because repos (a slice of models.Repository) does not contain these fields. To provide a complete JSON response, consider defining a temporary struct that embeds models.Repository and adds the new fields, then populating and returning that instead.
| ### Workspaces | ||
|
|
||
| | Command | Description | | ||
| |---|---| | ||
| | `bb workspace members` | List workspace members (`--workspace`, `--limit`, `--format`) | |
There was a problem hiding this comment.
Documentation for bb workspace members is being added, but the implementation of this command is not present in this pull request. This could lead to user confusion if they attempt to use a command that hasn't been implemented yet. Please ensure the command is included in this PR or remove these documentation changes.
Summary
bb repo list --details— adds last commit date and open PR count columns, fetched concurrently with bounded parallelism (10 goroutines)bb repo move <slug> --project KEY— moves a repo to a different Bitbucket project, with optional--prefixfor renaming (e.g.--prefix "Archived-")api.Count()helper to get total size from a paginated endpoint without fetching all itemsTest plan
bb repo list --details --limit 5shows Last Commit and Open PRs columnsbb repo list(without --details) works as beforebb repo move <slug> --project <key>moves repo to target projectbb repo move <slug> --project <key> --prefix "Archived-"moves and renamesbb repo movewithout args shows errorbb repo move <slug>without --project shows error