Skip to content

Commit 5713a3c

Browse files
xTrayambakAraq
andauthored
Be less ambiguous when a project isn't under a VCS like Git or Mercurial (#1224)
* (fix) fixes #1180; add a hint when failing to fetch VCS revision * Apply suggestions from code review --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
1 parent be2f130 commit 5713a3c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/nimblepkg/packageparser.nim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,12 @@ proc readPackageInfo(pkgInfo: var PackageInfo, nf: NimbleFile, options: Options,
349349
## This version uses a cache stored in ``options``, so calling it multiple
350350
## times on the same ``nf`` shouldn't require re-evaluation of the Nimble
351351
## file.
352-
353352
assert fileExists(nf)
354353

355354
# Check the cache.
356355
if options.pkgInfoCache.hasKey(nf):
357356
pkgInfo = options.pkgInfoCache[nf]
358357
return
359-
360358
pkgInfo = initPackageInfo(options, nf)
361359
pkgInfo.isLink = not nf.startsWith(options.getPkgsDir)
362360

@@ -399,7 +397,13 @@ proc readPackageInfo(pkgInfo: var PackageInfo, nf: NimbleFile, options: Options,
399397
pkgInfo.metaData.specialVersions.incl pkgInfo.basicInfo.version
400398
# If the `fileDir` is a VCS repository we can get some of the package meta
401399
# data from it.
402-
pkgInfo.metaData.vcsRevision = getVcsRevision(fileDir)
400+
try:
401+
pkgInfo.metaData.vcsRevision = getVcsRevision(fileDir)
402+
except CatchableError:
403+
raise nimbleError(
404+
msg = "Failed to get VCS revision of your project!",
405+
hint = "Try making a commit to your project if you haven't made one yet."
406+
)
403407

404408
case getVcsType(fileDir)
405409
of vcsTypeGit: pkgInfo.metaData.downloadMethod = DownloadMethod.git

src/nimblepkg/syncfile.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ proc getSyncFilePath(pkgInfo: PackageInfo): Path =
4848
raise nimbleError(
4949
msg = "Sync file require current working directory to be under some " &
5050
"supported type of version control.",
51-
hint = "Put package's working directory under version control.")
51+
hint = "Put package's working directory under version control and create a commit to continue.")
5252

5353
return vcsSpecialDirPath / (pkgInfo.basicInfo.name & syncFileExt).Path
5454

0 commit comments

Comments
 (0)