fix repo description setting bugs

* init: When the repository already has a description, don't change it.
* describe: When run with no description parameter it used to set
  the description to "", now it will error out.
This commit is contained in:
Joey Hess 2019-05-23 12:51:01 -04:00
parent b646a85c4a
commit a14f6ce758
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 29 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{- git-annex repository initialization {- git-annex repository initialization
- -
- Copyright 2011-2017 Joey Hess <id@joeyh.name> - Copyright 2011-2019 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
@ -52,6 +52,8 @@ import System.Posix.User
import qualified Utility.LockFile.Posix as Posix import qualified Utility.LockFile.Posix as Posix
#endif #endif
import qualified Data.Map as M
checkCanInitialize :: Annex a -> Annex a checkCanInitialize :: Annex a -> Annex a
checkCanInitialize a = inRepo (noAnnexFileContent . Git.repoWorkTree) >>= \case checkCanInitialize a = inRepo (noAnnexFileContent . Git.repoWorkTree) >>= \case
Nothing -> a Nothing -> a
@ -88,7 +90,10 @@ initialize mdescription mversion = checkCanInitialize $ do
initSharedClone sharedclone initSharedClone sharedclone
u <- getUUID u <- getUUID
describeUUID u =<< genDescription mdescription {- Avoid overwriting existing description with a default
- description. -}
whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMap) $
describeUUID u =<< genDescription mdescription
-- Everything except for uuid setup, shared clone setup, and initial -- Everything except for uuid setup, shared clone setup, and initial
-- description. -- description.

View file

@ -13,6 +13,9 @@ git-annex (7.20190508) UNRELEASED; urgency=medium
import with such an expression will fail. import with such an expression will fail.
* Improve shape of commit tree when importing from unversioned special * Improve shape of commit tree when importing from unversioned special
remotes. remotes.
* init: When the repository already has a description, don't change it.
* describe: When run with no description parameter it used to set
the description to "", now it will error out.
-- Joey Hess <id@joeyh.name> Mon, 06 May 2019 13:52:02 -0400 -- Joey Hess <id@joeyh.name> Mon, 06 May 2019 13:52:02 -0400

View file

@ -21,7 +21,7 @@ seek :: CmdParams -> CommandSeek
seek = withWords (commandAction . start) seek = withWords (commandAction . start)
start :: [String] -> CommandStart start :: [String] -> CommandStart
start (name:description) = do start (name:description) | not (null description) = do
showStart' "describe" (Just name) showStart' "describe" (Just name)
u <- Remote.nameToUUID name u <- Remote.nameToUUID name
next $ perform u $ unwords description next $ perform u $ unwords description

View file

@ -18,3 +18,5 @@ upgrade supported from repository versions: 0 1 2 3 4 5 6
local repository version: 5 local repository version: 5
(master_env_v135_py36) 13:47 [r2] $ uname -a (master_env_v135_py36) 13:47 [r2] $ uname -a
Linux ip-172-31-90-58.ec2.internal 4.14.114-105.126.amzn2.x86_64 #1 SMP Tue May 7 02:26:40 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Linux ip-172-31-90-58.ec2.internal 4.14.114-105.126.amzn2.x86_64 #1 SMP Tue May 7 02:26:40 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,16 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2019-05-23T16:40:50Z"
content="""
Yikes, I was surprised to see this behavior. fixed for `init`.
For `describe`, I see that when it's run with no parameter for the
description, it sets the description to "". I suppose that's what you
meant.
I suppose something could conceivably depend on the current `git annex
describe remote` behavior, but I checked and it's nowhere documented that
describe with no description is allowed -- even the --help doesn't say that
luckily. So I have also disallowed that.
"""]]