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

Method UncommittedChangeCount

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

Source from the content-addressed store, hash-verified

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