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

Method PathFromRoot

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

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

Calls 2

revParseMethod · 0.95
firstLineFunction · 0.70