MCPcopy
hub / github.com/cli/cli / UncommittedChangeCount

Method UncommittedChangeCount

git/client.go:284–302  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

282}
283
284func (c *Client) UncommittedChangeCount(ctx context.Context) (int, error) {
285 args := []string{"status", "--porcelain"}
286 cmd, err := c.Command(ctx, args...)
287 if err != nil {
288 return 0, err
289 }
290 out, err := cmd.Output()
291 if err != nil {
292 return 0, err
293 }
294 lines := strings.Split(string(out), "\n")
295 count := 0
296 for _, l := range lines {
297 if l != "" {
298 count++
299 }
300 }
301 return count, nil
302}
303
304func (c *Client) Commits(ctx context.Context, baseRef, headRef string) ([]*Commit, error) {
305 // The formatting directive %x00 indicates that git should include the null byte as a separator.

Callers 3

IsDirtyMethod · 0.80
NewCreateContextFunction · 0.80

Calls 2

CommandMethod · 0.95
OutputMethod · 0.65

Tested by 1