ScanRepositoryUsingGraph scans `repo`, using `rg` to decide which references to scan and how to group them. `nameStyle` specifies whether the output should include full names, hashes only, or nothing in the footnotes. `progress` tells whether a progress meter should be displayed while it works. It
( repo *git.Repository, rg RefGrouper, nameStyle NameStyle, progressMeter meter.Progress, )
| 63 | // |
| 64 | // It returns the size data for the repository. |
| 65 | func ScanRepositoryUsingGraph( |
| 66 | repo *git.Repository, rg RefGrouper, nameStyle NameStyle, |
| 67 | progressMeter meter.Progress, |
| 68 | ) (HistorySize, error) { |
| 69 | ctx, cancel := context.WithCancel(context.TODO()) |
| 70 | defer cancel() |
| 71 | |
| 72 | graph := NewGraph(rg, nameStyle) |
| 73 | |
| 74 | refIter, err := repo.NewReferenceIter(ctx) |
| 75 | if err != nil { |
| 76 | return HistorySize{}, err |
| 77 | } |
| 78 | |
| 79 | objIter, err := repo.NewObjectIter(context.TODO()) |
| 80 | if err != nil { |
| 81 | return HistorySize{}, err |
| 82 | } |
| 83 | |
| 84 | errChan := make(chan error, 1) |
| 85 | var refsSeen []refSeen |
| 86 | // Feed the references that we want into the stdin of the object |
| 87 | // iterator: |
| 88 | go func() { |
| 89 | defer objIter.Close() |
| 90 | |
| 91 | errChan <- func() error { |
| 92 | for { |
| 93 | ref, ok, err := refIter.Next() |
| 94 | if err != nil { |
| 95 | return err |
| 96 | } |
| 97 | if !ok { |
| 98 | return nil |
| 99 | } |
| 100 | |
| 101 | walk, groups := rg.Categorize(ref.Refname) |
| 102 | |
| 103 | refsSeen = append( |
| 104 | refsSeen, |
| 105 | refSeen{ |
| 106 | Reference: ref, |
| 107 | walked: walk, |
| 108 | groups: groups, |
| 109 | }, |
| 110 | ) |
| 111 | |
| 112 | if !walk { |
| 113 | continue |
| 114 | } |
| 115 | |
| 116 | if err := objIter.AddRoot(ref.OID); err != nil { |
| 117 | return err |
| 118 | } |
| 119 | } |
| 120 | }() |
| 121 | }() |
| 122 |