@@ -13,6 +13,7 @@ import (
13
13
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
14
14
"github.com/github/gh-classroom/pkg/classroom"
15
15
"github.com/spf13/cobra"
16
+ "github.com/github/gh-classroom/cmd/gh-classroom/clone/utils"
16
17
)
17
18
18
19
func NewCmdStudentRepo (f * cmdutil.Factory ) * cobra.Command {
@@ -90,17 +91,24 @@ func NewCmdStudentRepo(f *cmdutil.Factory) *cobra.Command {
90
91
91
92
totalCloned := 0
92
93
for _ , acceptAssignment := range acceptedAssignmentList .AcceptedAssignments {
93
- clonePath := filepath .Join (fullPath , acceptAssignment .Repository .Name ())
94
- if _ , err := os .Stat (clonePath ); os .IsNotExist (err ) {
95
- fmt .Printf ("Cloning into: %v\n " , clonePath )
96
- _ , _ , err := gh .Exec ("repo" , "clone" , acceptAssignment .Repository .FullName , "--" , clonePath )
97
- totalCloned ++
98
- if err != nil {
99
- log .Fatal (err )
100
- return
101
- }
94
+ clonePath := filepath .Join (fullPath , acceptAssignment .Repository .Name )
95
+ _ , err := CloneRepository (clonePath , acceptAssignment .Repository .FullName , gh )
96
+ if err != nil {
97
+ errMsg := fmt .Sprintf ("Error cloning %s: %v" , acceptAssignment .Repository .FullName , err )
98
+ fmt .Println (errMsg )
99
+ cloneErrors = append (cloneErrors , errMsg )
100
+ continue // Continue with the next iteration
101
+ }
102
+ totalCloned ++
103
+ }
104
+ if len (cloneErrors ) > 0 {
105
+ fmt .Println ("Some repositories failed to clone." )
106
+ if ! verbose {
107
+ fmt .Println ("Run with --verbose flag to see more details" )
102
108
} else {
103
- fmt .Printf ("Skip existing repo: %v use gh classroom pull to get new commits\n " , clonePath )
109
+ for _ , errMsg := range cloneErrors {
110
+ fmt .Println (errMsg )
111
+ }
104
112
}
105
113
}
106
114
if getAll {
@@ -117,6 +125,7 @@ func NewCmdStudentRepo(f *cmdutil.Factory) *cobra.Command {
117
125
cmd .Flags ().IntVar (& page , "page" , 1 , "Page number" )
118
126
cmd .Flags ().IntVar (& perPage , "per-page" , 15 , "Number of accepted assignments per page" )
119
127
cmd .Flags ().BoolVar (& getAll , "all" , true , "Clone All assignments by default" )
128
+ cmd .Flags ().BoolVarP (& verbose , "verbose" , "v" , false , "Enable verbose error output" )
120
129
121
130
return cmd
122
131
}
0 commit comments