Skip to content

Commit

Permalink
feat(repo/clone): Add options for page and page size (profclems#942)
Browse files Browse the repository at this point in the history
This adds the missing options for setting page number and page size for
repo clone to allow for cloning more then 100 repos.

Issue profclems#941
  • Loading branch information
zemzale committed Jan 19, 2022
1 parent e018da7 commit 741a1fc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion commands/project/clone/repo_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type CloneOptions struct {
Host string
Protocol string

Page int
PerPage int

IO *iostreams.IOStreams
APIClient *api.Client
Config func() (config.Config, error)
Expand Down Expand Up @@ -138,6 +141,8 @@ Clone a GitLab repository/project
repoCloneCmd.Flags().BoolVarP(&opts.WithIssuesEnabled, "with-issues-enabled", "I", false, "Limit by projects with issues feature enabled. Default is false. Used with --group flag")
repoCloneCmd.Flags().BoolVarP(&opts.WithMREnabled, "with-mr-enabled", "M", false, "Limit by projects with issues feature enabled. Default is false. Used with --group flag")
repoCloneCmd.Flags().BoolVarP(&opts.WithShared, "with-shared", "S", false, "Include projects shared to this group. Default is false. Used with --group flag")
repoCloneCmd.Flags().IntVarP(&opts.Page, "page", "", 1, "Page number")
repoCloneCmd.Flags().IntVarP(&opts.PerPage, "per-page", "", 30, "Number of items to list per page")

repoCloneCmd.Flags().SortFlags = false
repoCloneCmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error {
Expand Down Expand Up @@ -174,7 +179,13 @@ func groupClone(opts *CloneOptions, ctxOpts *ContextOpts) error {
if opts.Visibility != "" {
ListGroupProjectOpts.Visibility = gitlab.Visibility(gitlab.VisibilityValue(opts.Visibility))
}
ListGroupProjectOpts.PerPage = 100 //TODO: Allow user to specify the page and limit
ListGroupProjectOpts.PerPage = 100
if opts.PerPage != 0 {
ListGroupProjectOpts.PerPage = opts.PerPage
}
if opts.Page != 0 {
ListGroupProjectOpts.Page = opts.Page
}
projects, err := api.ListGroupProjects(opts.APIClient.Lab(), opts.GroupName, ListGroupProjectOpts)
if err != nil {
return err
Expand Down

0 comments on commit 741a1fc

Please sign in to comment.