MCPcopy
hub / github.com/cli/cli / PathFromRoot

Method PathFromRoot

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

682
683// Show current directory relative to the top-level directory of repository.
684func (c *Client) PathFromRoot(ctx context.Context) string {
685 out, err := c.revParse(ctx, "--show-prefix")
686 if err != nil {
687 return ""
688 }
689 if path := firstLine(out); path != "" {
690 return path[:len(path)-1]
691 }
692 return ""
693}
694
695func (c *Client) revParse(ctx context.Context, args ...string) ([]byte, error) {
696 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