fix API response path

This commit is contained in:
Denis Bilenko 2024-11-28 16:54:04 +01:00
parent 0905d36e9d
commit 0c00ddef72
1 changed files with 9 additions and 1 deletions

View File

@ -69,11 +69,12 @@ func FetchRepositoryInfoAPI(ctx context.Context, path vfs.Path, w *databricks.Wo
gi := response.GitInfo
// XXX log warning if missing
if gi != nil {
fixedPath := fixResponsePath(gi.Path)
return GitRepositoryInfo{
OriginURL: gi.URL,
LatestCommit: gi.HeadCommitID,
CurrentBranch: gi.Branch,
WorktreeRoot: vfs.MustNew(gi.Path),
WorktreeRoot: vfs.MustNew(fixedPath),
}, nil
}
@ -82,6 +83,13 @@ func FetchRepositoryInfoAPI(ctx context.Context, path vfs.Path, w *databricks.Wo
}, nil
}
func fixResponsePath(path string) string {
if strings.HasPrefix(path, "/Users/") {
return "/Workspace/" + path
}
return path
}
func FetchRepositoryInfoDotGit(ctx context.Context, path vfs.Path) (GitRepositoryInfo, error) {
rootDir, err := vfs.FindLeafInTree(path, GitDirectoryName)
if err != nil {