Skip to content

Commit 2960ac0

Browse files
committed
Fix #66: print correct revision in push-cabal --incr-rev
Closes #66.
1 parent aea4eef commit 2960ac0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

hackage-cli.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ executable hackage-cli
114114
, mtl
115115

116116
build-depends:
117-
, aeson >= 1.2.4.0 && < 2.3
117+
, aeson >= 1.2.4.0 && < 2.3
118118
-- aeson-1.2.4.0 for stack-8.2.2.yaml
119+
, base-compat >= 0.13.0 && < 1
120+
-- base-compat for applyWhen (added to base in 4.18)
119121
, deepseq ^>= 1.4.0.0 || ^>= 1.5.0.0
120122
, directory ^>= 1.2.0.1 || ^>= 1.3.0.0
121123
, filepath >= 1.4.0.0 && < 2

src/Main.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import qualified Data.ByteString.Lazy as BSL
3131
import qualified Data.ByteString.Search as BSS
3232
import Data.Char (isSpace)
3333
import Data.Foldable (toList)
34+
import Data.Function.Compat (applyWhen)
3435
import qualified Data.List as List
3536
import Data.Maybe
3637
import Data.Time.Clock.POSIX (getPOSIXTime)
@@ -735,18 +736,18 @@ mainWithOptions Options {..} = do
735736
putStrLn $ "Using Hackage credentials for username " ++ show username
736737

737738
forM_ optPsCFiles $ \fn -> do
738-
(pkgn,pkgv,xrev) <- pkgDescToPkgIdXrev <$> C.readGenericPackageDescription C.deafening fn
739+
(pkgn, pkgv, xrev0) <- pkgDescToPkgIdXrev <$> C.readGenericPackageDescription C.deafening fn
740+
let xrev = applyWhen optPsCIncrRev (+1) xrev0
741+
739742
putStrLn $ concat [ "Pushing ", show fn
740743
, " (", BS8.unpack pkgn, "-", BS8.unpack pkgv, "~", show xrev, ")"
741744
, if not optPsCPublish then " [review-mode]" else "", " ..."
742745
]
743746

744-
let editCab | optPsCIncrRev = cabalEditXRev (xrev+1)
745-
| otherwise = id
746-
747-
rawcab <- editCab <$> BS.readFile fn
748-
(dt,tmp) <- timeIt $ runHConn (hackagePostCabal (username,password) (pkgn,pkgv) rawcab
749-
(if optPsCPublish then WetRun else DryRun))
747+
rawcab <- applyWhen optPsCIncrRev (cabalEditXRev xrev) <$> BS.readFile fn
748+
(dt, tmp) <- timeIt $ runHConn $
749+
hackagePostCabal (username, password) (pkgn, pkgv) rawcab $
750+
if optPsCPublish then WetRun else DryRun
750751

751752
printf "Hackage response was (after %.3f secs):\n" dt
752753
putStrLn (replicate 80 '=')

0 commit comments

Comments
 (0)