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

Method PathFromRoot

git/client.go:747–756  ·  view source on GitHub ↗

Show current directory relative to the top-level directory of repository.

(ctx context.Context)

Source from the content-addressed store, hash-verified

745
746// Show current directory relative to the top-level directory of repository.
747func (c *Client) PathFromRoot(ctx context.Context) string {
748 out, err := c.revParse(ctx, "--show-prefix")
749 if err != nil {
750 return ""
751 }
752 if path := firstLine(out); path != "" {
753 return path[:len(path)-1]
754 }
755 return ""
756}
757
758func (c *Client) revParse(ctx context.Context, args ...string) ([]byte, error) {
759 args = append([]string{"rev-parse"}, args...)

Callers 2

TestClientPathFromRootFunction · 0.95
NewCmdBrowseFunction · 0.80

Calls 2

revParseMethod · 0.95
firstLineFunction · 0.85

Tested by 1

TestClientPathFromRootFunction · 0.76