Skip to content

UX Change to show checksums and git commits in deps output #1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/nimblepkg/deps.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tables, strformat, sequtils, algorithm, cli
import packageinfotypes, developfile, packageinfo, version
import packageinfotypes, developfile, packageinfo, sha1hashes, version

type
DependencyNode = ref object of RootObj
Expand Down Expand Up @@ -42,10 +42,12 @@ proc printDepsHumanReadable*(pkgInfo: PackageInfo,
##
if levelInfos.len() == 0:
displayLineReset()
displayInfo("Dependency tree format: {PackageName} {Requirements} (@{Resolved Version})")
displayInfo("Dependency tree format: {PackageName} {Requirements} (@{Resolved Version} commit {short-hash-id})")
displayFormatted(Hint, "\n")
displayFormatted(Message, pkgInfo.basicInfo.name, " ")
displayFormatted(Success, "(@", $pkgInfo.basicInfo.version, ")")
displayFormatted(Details, " [vcs: ", pkgInfo.metaData.vcsRevision.shortId(),
" checksum: ", pkgInfo.basicInfo.checksum.shortId(), "]")

var requires: seq[(string, VersionRange, bool, PackageInfo)]
for idx, (name, ver) in pkgInfo.requires.sorted():
Expand Down Expand Up @@ -78,6 +80,8 @@ proc printDepsHumanReadable*(pkgInfo: PackageInfo,
displayFormatted(Hint, " ")
if found:
displayFormatted(Success, fmt"(@{depPkgInfo.basicInfo.version})")
displayFormatted(Details, " [vcs: ", depPkgInfo.metaData.vcsRevision.shortId(),
" checksum: ", depPkgInfo.basicInfo.checksum.shortId(), "]")
if errors.contains(packageName):
let errMsg = getValidationErrorMessage(packageName, errors.getOrDefault packageName)
displayFormatted(Error, fmt" - error: {errMsg}")
Expand All @@ -100,11 +104,13 @@ proc printDepsHumanReadableInverted*(pkgInfo: PackageInfo,
isRoot = pkgs.len() == 0

if isRoot:
displayInfo("Dependency tree format: {PackageName} (@{Resolved Version})")
displayInfo("Dependency tree format: {PackageName} (@{Resolved Version} commit {short-hash-id})")
displayInfo("Dependency tree format: {Source Package} {Source Requirements}")
displayFormatted(Hint, "\n")
displayFormatted(Message, pkgInfo.basicInfo.name, " ")
displayFormatted(Success, "(@", $pkgInfo.basicInfo.version, ")")
displayFormatted(Details, " [vcs: ", pkgInfo.metaData.vcsRevision.shortId(),
" checksum: ", pkgInfo.basicInfo.checksum.shortId(), "]")
displayFormatted(Hint, "\n")

for (name, ver) in pkgInfo.requires:
Expand All @@ -128,8 +134,7 @@ proc printDepsHumanReadableInverted*(pkgInfo: PackageInfo,
displayFormatted(Hint, "├── ")
else:
displayFormatted(Hint, "└── ")
displayFormatted(Message, name, " ")
displayFormatted(Success, "(@", $pkgInfo.basicInfo.version, ")")
displayFormatted(Message, name)
displayFormatted(Hint, "\n")
# echo "name: ", pkg, " info: ", $info
# for idx, (source, ver) in info.pairs().toSeq():
Expand Down
1 change: 1 addition & 0 deletions src/nimblepkg/sha1hashes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ template `$`*(sha1Hash: Sha1Hash): string = sha1Hash.hashValue
template `%`*(sha1Hash: Sha1Hash): JsonNode = %sha1Hash.hashValue
template `==`*(lhs, rhs: Sha1Hash): bool = lhs.hashValue == rhs.hashValue
template hash*(sha1Hash: Sha1Hash): Hash = sha1Hash.hashValue.hash
template shortId*(sha1Hash: Sha1Hash): string = sha1Hash.hashValue[0..8]

proc invalidSha1Hash(value: string): ref InvalidSha1HashError =
## Creates a new exception object for an invalid sha1 hash value.
Expand Down
7 changes: 6 additions & 1 deletion tests/testscommon.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sequtils, strutils, strformat, os, osproc, sugar, unittest, macros
import pkg/checksums/sha1

import nimblepkg/cli
from nimblepkg/common import cd, nimblePackagesDirName, ProcessOutput
from nimblepkg/developfile import developFileVersion

Expand Down Expand Up @@ -70,7 +71,8 @@ template verify*(res: (string, int)) =
check r[1] == QuitSuccess

proc processOutput*(output: string): seq[string] =
output.strip.splitLines().filter(
checkpoint(output)
result = output.strip.splitLines().filter(
(x: string) => (
x.len > 0 and
"Using env var NIM_LIB_PREFIX" notin x
Expand Down Expand Up @@ -207,6 +209,9 @@ proc writeDevelopFile*(path: string, includes: seq[string],
# Set env var to propagate nimble binary path
putEnv("NIMBLE_TEST_BINARY_PATH", nimblePath)

setVerbosity(MediumPriority)
setShowColor(false)

# Always recompile.
block:
# Verbose name is used for exit code so assert is clearer
Expand Down
Loading