Show current directory relative to the top-level directory of repository.
(ctx context.Context)
| 742 | |
| 743 | // Show current directory relative to the top-level directory of repository. |
| 744 | func (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 | |
| 755 | func (c *Client) revParse(ctx context.Context, args ...string) ([]byte, error) { |
| 756 | args = append([]string{"rev-parse"}, args...) |