Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cffc3b499 | |||
| 71cb6dd850 | |||
| f800a99dcc |
@@ -663,11 +663,17 @@ func (s *Source) scan(ctx context.Context, installationClient *github.Client, ch
|
|||||||
defer func(start time.Time) {
|
defer func(start time.Time) {
|
||||||
logger.V(2).Info(fmt.Sprintf("scanned %d/%d repos", scanned, len(s.repos)), "repo_size", repoSize, "duration_seconds", time.Since(start).Seconds())
|
logger.V(2).Info(fmt.Sprintf("scanned %d/%d repos", scanned, len(s.repos)), "repo_size", repoSize, "duration_seconds", time.Since(start).Seconds())
|
||||||
}(now)
|
}(now)
|
||||||
|
|
||||||
|
fmt.Printf("Scanning repoURL %s, path %+v, repo %+v \n ", repoURL, path, repo)
|
||||||
if err = s.git.ScanRepo(ctx, repo, path, s.scanOptions, chunksChan); err != nil {
|
if err = s.git.ScanRepo(ctx, repo, path, s.scanOptions, chunksChan); err != nil {
|
||||||
scanErrs.Add(fmt.Errorf("error scanning repo %s: %w", repoURL, err))
|
scanErrs.Add(fmt.Errorf("error scanning repo %s: %w", repoURL, err))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
atomic.AddUint64(&scanned, 1)
|
atomic.AddUint64(&scanned, 1)
|
||||||
|
fmt.Println("SCANNNNN COMMENTS")
|
||||||
|
if err = s.scanComments(ctx, repoURL, chunksChan); err != nil {
|
||||||
|
fmt.Println("test")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -916,3 +922,82 @@ func (s *Source) setProgressCompleteWithRepo(index int, offset int, repoURL stri
|
|||||||
|
|
||||||
s.SetProgressComplete(index+offset, len(s.repos)+offset, fmt.Sprintf("Repo: %s", repoURL), encodedResumeInfo)
|
s.SetProgressComplete(index+offset, len(s.repos)+offset, fmt.Sprintf("Repo: %s", repoURL), encodedResumeInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Source) scanComments(ctx context.Context, repoPath string, chunksChan chan *sources.Chunk) error {
|
||||||
|
s.log.Info("scanning comments")
|
||||||
|
fmt.Print("repoPath: ", repoPath, "\n")
|
||||||
|
|
||||||
|
trimmedURL := removeURLAndSplit(repoPath)
|
||||||
|
owner := trimmedURL[1]
|
||||||
|
repo := trimmedURL[2]
|
||||||
|
|
||||||
|
//for _, part := range trimmedURL {
|
||||||
|
// fmt.Println(part)
|
||||||
|
//}
|
||||||
|
|
||||||
|
sortType := "created"
|
||||||
|
directionType := "desc"
|
||||||
|
|
||||||
|
issueOpts := &github.IssueListCommentsOptions{
|
||||||
|
Sort: &sortType,
|
||||||
|
Direction: &directionType,
|
||||||
|
ListOptions: github.ListOptions{
|
||||||
|
PerPage: defaultPagination,
|
||||||
|
Page: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
issueComments, resp, err := s.apiClient.Issues.ListComments(ctx, owner, repo, 0, issueOpts)
|
||||||
|
|
||||||
|
prOpts := &github.PullRequestListCommentsOptions{
|
||||||
|
Sort: sortType,
|
||||||
|
Direction: directionType,
|
||||||
|
ListOptions: github.ListOptions{
|
||||||
|
PerPage: defaultPagination,
|
||||||
|
Page: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
prComments, resp, err := s.apiClient.PullRequests.ListComments(ctx, owner, repo, 0, prOpts)
|
||||||
|
|
||||||
|
fmt.Println("issue comments: ", issueComments)
|
||||||
|
fmt.Println("pr comments: ", prComments)
|
||||||
|
fmt.Println("resp: ", resp)
|
||||||
|
fmt.Println("err: ", err)
|
||||||
|
|
||||||
|
//for _, comment := range comments {
|
||||||
|
// // Create chunk and send it to the channel.
|
||||||
|
// chunk := &sources.Chunk{
|
||||||
|
// SourceName: s.name,
|
||||||
|
// SourceID: s.SourceID(),
|
||||||
|
// SourceType: s.Type(),
|
||||||
|
// SourceMetadata: &source_metadatapb.MetaData{
|
||||||
|
// Data: &source_metadatapb.MetaData_Github{
|
||||||
|
// Github: &source_metadatapb.Github{
|
||||||
|
// Link: sanitizer.UTF8(comment.GetHTMLURL()),
|
||||||
|
// Username: sanitizer.UTF8(comment.GetUser().GetLogin()),
|
||||||
|
// Email: sanitizer.UTF8(comment.GetUser().GetEmail()),
|
||||||
|
// Repository: sanitizer.UTF8(repo),
|
||||||
|
// Timestamp: sanitizer.UTF8(comment.GetCreatedAt().String()),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// Data: []byte(sanitizer.UTF8(comment.GetBody())),
|
||||||
|
// Verify: s.verify,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// select {
|
||||||
|
// case <-ctx.Done():
|
||||||
|
// return ctx.Err()
|
||||||
|
// case chunksChan <- chunk:
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeURLAndSplit(url string) []string {
|
||||||
|
trimmedURL := strings.TrimPrefix(url, "https://")
|
||||||
|
trimmedURL = strings.TrimSuffix(trimmedURL, ".git")
|
||||||
|
splitURL := strings.Split(trimmedURL, "/")
|
||||||
|
|
||||||
|
return splitURL
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user