Skip to content

Commit

Permalink
Fix minor issue after PR #7934
Browse files Browse the repository at this point in the history
As written in the comments current_ts can be a non valid timestamp
(nullTimestamp) if the timestamp is missing. In this case it does not
make sense to tell the user how to revert to current_ts.
  • Loading branch information
andreabedini committed May 9, 2022
1 parent 5e580dd commit 4ceabf6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cabal-install/src/Distribution/Client/CmdUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )

import qualified Hackage.Security.Client as Sec
import Distribution.Client.IndexUtils.Timestamp (nullTimestamp)

updateCommand :: CommandUI (NixStyleFlags ())
updateCommand = CommandUI
Expand Down Expand Up @@ -227,7 +228,10 @@ updateRepo verbosity _updateFlags repoCtxt (repo, indexState) = do
-- TODO: This will print multiple times if there are multiple
-- repositories: main problem is we don't have a way of updating
-- a specific repo. Once we implement that, update this.
when (new_ts /= current_ts) $

-- In case current_ts is a valid timestamp different from new_ts, let
-- the user know how to go back to current_ts
when (current_ts /= nullTimestamp && new_ts /= current_ts) $
noticeNoWrap verbosity $
"To revert to previous state run:\n" ++
" cabal v2-update '" ++ prettyShow (UpdateRequest rname (IndexStateTime current_ts)) ++ "'\n"
" cabal v2-update '" ++ prettyShow (UpdateRequest rname (IndexStateTime current_ts)) ++ "'\n"
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Warning: No mirrors found for http://localhost:8000/
Downloading the latest package list from repository.localhost
Package list of repository.localhost has been updated.
The index-state is set to 2022-01-28T02:36:41Z.
To revert to previous state run:
cabal v2-update 'repository.localhost,'
# cabal update
Downloading the latest package list from repository.localhost
Package list of repository.localhost is up to date.
Expand Down

0 comments on commit 4ceabf6

Please sign in to comment.