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

Method PathFromRoot

git/client.go:746–755  ·  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

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