Skip to content

Improve pretty-printing of sha256 #2189

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

Merged
merged 2 commits into from
May 19, 2021
Merged
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
10 changes: 9 additions & 1 deletion dhall/src/Dhall/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,15 @@ instance Pretty ImportHashed where
pretty (ImportHashed Nothing p) =
Pretty.pretty p
pretty (ImportHashed (Just h) p) =
Pretty.pretty p <> " sha256:" <> Pretty.pretty (show h)
Pretty.group (Pretty.flatAlt long short)
where
long =
Pretty.align
( Pretty.pretty p <> Pretty.hardline
<> " sha256:" <> Pretty.pretty (show h)
)

short = Pretty.pretty p <> " sha256:" <> Pretty.pretty (show h)

-- | Reference to an external resource
data Import = Import
Expand Down
3 changes: 2 additions & 1 deletion dhall/tests/format/ipfsB.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let matchLabels =
labels.{ `app.kubernetes.io/name`, `app.kubernetes.io/instance` }

let k8s =
https://raw.githubusercontent.com/dhall-lang/dhall-kubernetes/4ab28225a150498aef67c226d3c5f026c95b5a1e/package.dhall sha256:2c7ac35494f16b1f39afcf3467b2f3b0ab579edb0c711cddd2c93f1cbed358bd
https://raw.githubusercontent.com/dhall-lang/dhall-kubernetes/4ab28225a150498aef67c226d3c5f026c95b5a1e/package.dhall
sha256:2c7ac35494f16b1f39afcf3467b2f3b0ab579edb0c711cddd2c93f1cbed358bd

let serviceName = "ipfs"

Expand Down
3 changes: 2 additions & 1 deletion dhall/tests/format/issue1400-2B.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ let Tagged
= λ(a : Type) →
{ field : Text
, nesting :
./Nesting sha256:6284802edd41d5d725aa1ec7687e614e21ad1be7e14dd10996bfa9625105c335
./Nesting
sha256:6284802edd41d5d725aa1ec7687e614e21ad1be7e14dd10996bfa9625105c335
? ./Nesting
, contents : a
}
Expand Down
3 changes: 2 additions & 1 deletion dhall/tests/format/sha256PrintingB.dhall
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let replicate =
https://raw.githubusercontent.com/dhall-lang/Prelude/c79c2bc3c46f129cc5b6d594ce298a381bcae92c/List/replicate sha256:cc856d59b63f7699881bdb8e4b1036ca4c0013827268040a50c1e1405f646a2c
https://raw.githubusercontent.com/dhall-lang/Prelude/c79c2bc3c46f129cc5b6d594ce298a381bcae92c/List/replicate
sha256:cc856d59b63f7699881bdb8e4b1036ca4c0013827268040a50c1e1405f646a2c

in replicate 5
3 changes: 2 additions & 1 deletion dhall/tests/freeze/cachedB.dhall
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./True.dhall sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
./True.dhall
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall
3 changes: 2 additions & 1 deletion dhall/tests/freeze/incorrectHashB.dhall
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./True.dhall sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
./True.dhall
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall
3 changes: 2 additions & 1 deletion dhall/tests/freeze/protectedB.dhall
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./True.dhall sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
./True.dhall
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall
3 changes: 2 additions & 1 deletion dhall/tests/freeze/unprotectedB.dhall
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./True.dhall sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
./True.dhall
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall