Skip to content

Commit ed2a2da

Browse files
committed
Use gitDescribe instead of embeddedRevision
Signed-off-by: Sasha Bogicevic <[email protected]>
1 parent 9ee9dd7 commit ed2a2da

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

hydra-node/src/Hydra/NetworkVersions.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Data.List qualified as List
1515
import Data.Text (pack, splitOn, toLower, unpack)
1616
import Data.Text.Encoding (encodeUtf8)
1717
import Hydra.Cardano.Api (TxId, deserialiseFromRawBytesHex)
18-
import Hydra.Version (embeddedRevision)
18+
import Hydra.Version (gitDescribe)
1919

2020
{-# NOINLINE networkVersions #-}
2121
networkVersions :: ByteString
@@ -31,10 +31,11 @@ parseNetworkTxIds networkString = do
3131
where
3232
getLastTxId t = do
3333
lastTxIds <-
34-
case embeddedRevision of
34+
case gitDescribe of
3535
Nothing -> Left "Missing hydra-node revision."
36-
Just rev ->
37-
case List.find (String (pack rev) ==) (KeyMap.elems t) of
36+
Just fullRev -> do
37+
let rev = List.head $ splitOn "-" $ pack fullRev
38+
case List.find (String rev ==) (KeyMap.elems t) of
3839
Just (String s) -> Right s
3940
_ -> Left "Failed to find released hydra-node version in networks.json."
4041
mapM parseToTxId (splitOn "," lastTxIds)

hydra-node/test/Hydra/OptionsSpec.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,15 @@ spec = parallel $
326326
}
327327

328328
it "parses --network into related tx ids" $ do
329+
-- NOTE: we should be able to parse both upper and lower case network names
329330
let networks = ["Mainnet", "preview", "Preprod"]
330331
forM_ networks $ \network -> do
331332
case parseNetworkTxIds network of
332-
Left err -> err `shouldBe` ("Failed to find released hydra-node version in networks.json." :: String)
333+
Left err ->
334+
err `shouldSatisfy` \case
335+
"Failed to find released hydra-node version in networks.json." -> True
336+
"Missing hydra-node revision." -> True
337+
_ -> False
333338
Right txIds ->
334339
["--network", network]
335340
`shouldParse` Run

0 commit comments

Comments
 (0)