Skip to content

Commit

Permalink
Fix two issues in the version cache code.
Browse files Browse the repository at this point in the history
- The constructed git ref path was off (existing version.json files pretended a working system).
- Using atomicWriteJsonFile to avoid issues with multiple DUB instances running in parallel.
- If no .dub directory existed, the version.json file wasn't written.
  • Loading branch information
s-ludwig committed Sep 22, 2015
1 parent 40c1296 commit 45308c7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/dub/package_.d
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ private string determineVersionFromSCM(Path path)
if (exists(hpath)) {
auto head_ref = readText(hpath).strip();
if (head_ref.startsWith("ref: ")) {
auto rpath = (path ~ head_ref[5 .. $]).toNativeString();
auto rpath = (path ~ (".git/"~head_ref[5 .. $])).toNativeString();
if (exists(rpath))
head_commit = readText(rpath).strip();
}
Expand All @@ -627,7 +627,10 @@ private string determineVersionFromSCM(Path path)
auto ret = determineVersionWithGIT(path);

// update version cache file
writeJsonFile(vcachepath, Json(["commit": Json(head_commit), "version": Json(ret)]));
if (head_commit.length) {
if (!existsFile(path ~".dub")) createDirectory(path ~ ".dub");
atomicWriteJsonFile(vcachepath, Json(["commit": Json(head_commit), "version": Json(ret)]));
}

return ret;
}
Expand Down

0 comments on commit 45308c7

Please sign in to comment.