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

Method UncommittedChangeCount

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

Source from the content-addressed store, hash-verified

338}
339
340func (c *Client) UncommittedChangeCount(ctx context.Context) (int, error) {
341 args := []string{"status", "--porcelain"}
342 cmd, err := c.Command(ctx, args...)
343 if err != nil {
344 return 0, err
345 }
346 out, err := cmd.Output()
347 if err != nil {
348 return 0, err
349 }
350 lines := strings.Split(string(out), "\n")
351 count := 0
352 for _, l := range lines {
353 if l != "" {
354 count++
355 }
356 }
357 return count, nil
358}
359
360func (c *Client) Commits(ctx context.Context, baseRef, headRef string) ([]*Commit, error) {
361 // The formatting directive %x00 indicates that git should include the null byte as a separator.

Calls 2

CommandMethod · 0.95
OutputMethod · 0.65