MCPcopy Create free account
hub / github.com/cli/cli / UncommittedChangeCount

Method UncommittedChangeCount

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

Source from the content-addressed store, hash-verified

345}
346
347func (c *Client) UncommittedChangeCount(ctx context.Context) (int, error) {
348 args := []string{"status", "--porcelain"}
349 cmd, err := c.Command(ctx, args...)
350 if err != nil {
351 return 0, err
352 }
353 out, err := cmd.Output()
354 if err != nil {
355 return 0, err
356 }
357 lines := strings.Split(string(out), "\n")
358 count := 0
359 for _, l := range lines {
360 if l != "" {
361 count++
362 }
363 }
364 return count, nil
365}
366
367func (c *Client) Commits(ctx context.Context, baseRef, headRef string) ([]*Commit, error) {
368 // 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