@@ -78,17 +78,9 @@ func (s githubService) OpenVulnerabilityIssue(project repository.Project, report
7878 return nil , errors .New ("OpenVulnerabilityIssue not yet implemented" ) // TODO #9 Add github support
7979}
8080
81- func (s githubService ) DownloadRepository (project repository.Project , dir string ) (err error ) {
82- // Extract owner and repo from project path (format: "owner/repo")
83- owner , repo , err := s .extractOwnerRepo (project .Path )
84- if err != nil {
85- return fmt .Errorf ("failed to extract owner/repo from path %s: %w" , project .Path , err )
86- }
87-
88- log .Debug ().Str ("owner" , owner ).Str ("repo" , repo ).Str ("dir" , dir ).Msg ("Downloading GitHub archive" )
89-
81+ func (s githubService ) Download (project repository.Project , dir string ) (err error ) {
9082 // Get archive download URL using GitHub API
91- archiveURL , _ , err := s .client .GetArchiveLink (owner , repo , github .Tarball , & github.RepositoryContentGetOptions {})
83+ archiveURL , _ , err := s .client .GetArchiveLink (project . GroupOrOwner , project . Name , github .Tarball , & github.RepositoryContentGetOptions {})
9284 if err != nil {
9385 return fmt .Errorf ("failed to get GitHub archive link: %w" , err )
9486 }
@@ -225,14 +217,22 @@ func derefRepoPtrs(owner string, repoPtrs []*github.Repository) (repos []github.
225217}
226218
227219func mapGithubProject (r github.Repository ) repository.Project {
220+ // log.Warn().Str("id", fmt.Sprint(r.GetID())).Str("name", r.GetName()).Str("full_name", r.GetFullName()).Str("owner", r.GetOwner().Name).Msg("Mapping GitHub project")
221+ var groupName = ""
222+ owner := r .GetOwner ()
223+ if owner != nil {
224+ groupName = owner .GetLogin ()
225+ }
226+
228227 return repository.Project {
229- ID : int (valueOrEmpty (r .ID )),
230- Name : valueOrEmpty (r .Name ),
231- Path : valueOrEmpty (r .FullName ),
232- Slug : valueOrEmpty (r .Name ),
233- WebURL : valueOrEmpty (r .HTMLURL ),
234- RepoUrl : valueOrEmpty (r .HTMLURL ),
235- Repository : repository .Github ,
228+ ID : int (valueOrEmpty (r .ID )),
229+ Name : valueOrEmpty (r .Name ),
230+ GroupOrOwner : valueOrEmpty (& groupName ),
231+ Path : valueOrEmpty (r .FullName ),
232+ Slug : valueOrEmpty (r .Name ),
233+ WebURL : valueOrEmpty (r .HTMLURL ),
234+ RepoUrl : valueOrEmpty (r .HTMLURL ),
235+ Repository : repository .Github ,
236236 }
237237}
238238
@@ -243,12 +243,3 @@ func valueOrEmpty[T interface{}](val *T) (r T) {
243243
244244 return r
245245}
246-
247- // extractOwnerRepo extracts owner and repo name from GitHub project path
248- func (s githubService ) extractOwnerRepo (path string ) (owner , repo string , err error ) {
249- parts := strings .Split (path , "/" )
250- if len (parts ) != 2 {
251- return "" , "" , fmt .Errorf ("invalid GitHub project path format, expected 'owner/repo', got: %s" , path )
252- }
253- return parts [0 ], parts [1 ], nil
254- }
0 commit comments