feat: attempt to source link directory dependencies

main
Henrik 2023-04-24 00:18:29 +02:00
parent 9ebc79338e
commit cf86cb4815
1 changed files with 18 additions and 6 deletions

View File

@ -34,8 +34,12 @@ def getGithubBaseUrl (gitUrl : String) : String := Id.run do
/-- /--
Obtain the Github URL of a project by parsing the origin remote. Obtain the Github URL of a project by parsing the origin remote.
-/ -/
def getProjectGithubUrl : IO String := do def getProjectGithubUrl (directory : System.FilePath := "." ) : IO String := do
let out ← IO.Process.output {cmd := "git", args := #["remote", "get-url", "origin"]} let out ← IO.Process.output {
cmd := "git",
args := #["remote", "get-url", "origin"],
cwd := directory
}
if out.exitCode != 0 then if out.exitCode != 0 then
throw <| IO.userError <| "git exited with code " ++ toString out.exitCode throw <| IO.userError <| "git exited with code " ++ toString out.exitCode
return out.stdout.trimRight return out.stdout.trimRight
@ -43,8 +47,12 @@ def getProjectGithubUrl : IO String := do
/-- /--
Obtain the git commit hash of the project that is currently getting analyzed. Obtain the git commit hash of the project that is currently getting analyzed.
-/ -/
def getProjectCommit : IO String := do def getProjectCommit (directory : System.FilePath := "." ) : IO String := do
let out ← IO.Process.output {cmd := "git", args := #["rev-parse", "HEAD"]} let out ← IO.Process.output {
cmd := "git",
args := #["rev-parse", "HEAD"]
cwd := directory
}
if out.exitCode != 0 then if out.exitCode != 0 then
throw <| IO.userError <| "git exited with code " ++ toString out.exitCode throw <| IO.userError <| "git exited with code " ++ toString out.exitCode
return out.stdout.trimRight return out.stdout.trimRight
@ -65,8 +73,12 @@ def sourceLinker (ws : Lake.Workspace) : IO (Name → Option DeclarationRange
|>.run (Lake.MonadLog.eio .normal) |>.run (Lake.MonadLog.eio .normal)
|>.toIO (fun _ => IO.userError "Failed to load lake manifest") |>.toIO (fun _ => IO.userError "Failed to load lake manifest")
for pkg in manifest.entryArray do for pkg in manifest.entryArray do
if let .git _ url rev .. := pkg then match pkg with
gitMap := gitMap.insert pkg.name (getGithubBaseUrl url, rev) | .git _ url rev .. => gitMap := gitMap.insert pkg.name (getGithubBaseUrl url, rev)
| .path _ path =>
let pkgBaseUrl := getGithubBaseUrl (← getProjectGithubUrl path)
let pkgCommit ← getProjectCommit path
gitMap := gitMap.insert pkg.name (pkgBaseUrl, pkgCommit)
return fun module range => return fun module range =>
let parts := module.components.map Name.toString let parts := module.components.map Name.toString