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