SearchCommit searches all files in the tree of a given commit
(commit *object.Commit, cb func(*Comment))
| 108 | |
| 109 | // SearchCommit searches all files in the tree of a given commit |
| 110 | func SearchCommit(commit *object.Commit, cb func(*Comment)) error { |
| 111 | var wg sync.WaitGroup |
| 112 | errs := make(chan error) |
| 113 | |
| 114 | fileIter, err := commit.Files() |
| 115 | if err != nil { |
| 116 | return err |
| 117 | } |
| 118 | defer fileIter.Close() |
| 119 | err = fileIter.ForEach(func(file *object.File) error { |
| 120 | if file.Mode.IsFile() { |
| 121 | wg.Add(1) |
| 122 | go func() { |
| 123 | defer wg.Done() |
| 124 | |
| 125 | r, err := file.Reader() |
| 126 | if err != nil { |
| 127 | errs <- err |
| 128 | return |
| 129 | } |
| 130 | err = SearchFile(file.Name, r, cb) |
| 131 | if err != nil { |
| 132 | errs <- err |
| 133 | return |
| 134 | } |
| 135 | |
| 136 | }() |
| 137 | } |
| 138 | return nil |
| 139 | }) |
| 140 | |
| 141 | if err != nil { |
| 142 | return err |
| 143 | } |
| 144 | |
| 145 | wg.Wait() |
| 146 | return nil |
| 147 | } |
nothing calls this directly
no test coverage detected