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