this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf(controller): shallow clone by default

Khue Doan 49b5a26e fd0dff58

+12 -2
+12 -2
controller/activities/git.go
··· 43 43 44 44 logger.Info("Cloning repository", "url", url, "revision", revision) 45 45 46 - cmd := exec.CommandContext(ctx, "git", "clone", "--branch", revision, url, path) 46 + cmd := exec.CommandContext(ctx, "git", "clone", "--depth", "1", "--branch", revision, url, path) 47 47 if err := cmd.Run(); err != nil { 48 48 os.RemoveAll(path) 49 49 return "", fmt.Errorf("failed to clone repository: %w", err) ··· 53 53 } 54 54 55 55 func ChangedModules(ctx context.Context, repoPath string, oldRevision string) ([]string, error) { 56 + logger := activity.GetLogger(ctx) 57 + 58 + // Since we now clone with depth 1, we need to fetch the oldRevision before we can diff against it 59 + logger.Info("Fetching old revision for comparison", "oldRevision", oldRevision) 60 + fetchCmd := exec.CommandContext(ctx, "git", "fetch", "origin", oldRevision) 61 + fetchCmd.Dir = repoPath 62 + if err := fetchCmd.Run(); err != nil { 63 + return nil, fmt.Errorf("failed to fetch old revision %s: %w", oldRevision, err) 64 + } 65 + 56 66 cmd := exec.CommandContext(ctx, "git", "diff", "--name-only", oldRevision, "HEAD") 57 67 cmd.Dir = repoPath 58 68 output, err := cmd.Output() 59 69 if err != nil { 60 - return nil, err 70 + return nil, fmt.Errorf("failed to run git diff: %w", err) 61 71 } 62 72 63 73 seen := make(map[string]struct{})