import: --message/-m option

This commit is contained in:
Joey Hess 2024-01-18 12:41:44 -04:00
parent 162c772703
commit e765d3e24c
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 45 additions and 6 deletions

View file

@ -12,6 +12,7 @@ git-annex (10.20231228) UNRELEASED; urgency=medium
key algorithm and size.
* Improve disk free space checking when transferring unsized keys to
local git remotes.
* import: --message/-m option.
-- Joey Hess <id@joeyh.name> Fri, 29 Dec 2023 11:52:06 -0400

View file

@ -70,6 +70,7 @@ data ImportOptions
, importToSubDir :: Maybe FilePath
, importContent :: Bool
, checkGitIgnoreOption :: CheckGitIgnore
, messageOption :: Maybe String
}
optParser :: CmdParamsDesc -> Parser ImportOptions
@ -81,7 +82,11 @@ optParser desc = do
)
dupmode <- fromMaybe Default <$> optional duplicateModeParser
ic <- Command.Add.checkGitIgnoreSwitch
return $ case mfromremote of
message <- optional (strOption
( long "message" <> short 'm' <> metavar "MSG"
<> help "commit message"
))
pure $ case mfromremote of
Nothing -> LocalImportOptions ps dupmode ic
Just r -> case ps of
[bs] ->
@ -91,6 +96,7 @@ optParser desc = do
(if null subdir then Nothing else Just subdir)
content
ic
message
_ -> giveup "expected BRANCH[:SUBDIR]"
data DuplicateMode = Default | Duplicate | DeDuplicate | CleanDuplicates | SkipDuplicates | ReinjectDuplicates
@ -141,7 +147,9 @@ seek o@(RemoteImportOptions {}) = startConcurrency commandStages $ do
(pure Nothing)
(Just <$$> inRepo . toTopFilePath . toRawFilePath)
(importToSubDir o)
seekRemote r (importToBranch o) subdir (importContent o) (checkGitIgnoreOption o)
seekRemote r (importToBranch o) subdir (importContent o)
(checkGitIgnoreOption o)
(messageOption o)
startLocal :: ImportOptions -> AddUnlockedMatcher -> GetFileMatcher -> DuplicateMode -> (RawFilePath, RawFilePath) -> CommandStart
startLocal o addunlockedmatcher largematcher mode (srcfile, destfile) =
@ -314,8 +322,8 @@ verifyExisting key destfile (yes, no) = do
verifyEnoughCopiesToDrop [] key Nothing needcopies mincopies [] preverified tocheck
(const yes) no
seekRemote :: Remote -> Branch -> Maybe TopFilePath -> Bool -> CheckGitIgnore -> CommandSeek
seekRemote remote branch msubdir importcontent ci = do
seekRemote :: Remote -> Branch -> Maybe TopFilePath -> Bool -> CheckGitIgnore -> Maybe String -> CommandSeek
seekRemote remote branch msubdir importcontent ci mimportmessage = do
importtreeconfig <- case msubdir of
Nothing -> return ImportTree
Just subdir ->
@ -345,7 +353,9 @@ seekRemote remote branch msubdir importcontent ci = do
includeCommandAction $
commitimport imported
where
importmessage = "import from " ++ Remote.name remote
importmessage = fromMaybe
("import from " ++ Remote.name remote)
mimportmessage
tb = mkRemoteTrackingBranch remote branch

View file

@ -591,7 +591,7 @@ importRemote importcontent o remote currbranch
let (branch, subdir) = splitRemoteAnnexTrackingBranchSubdir b
if canImportKeys remote importcontent
then do
Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True)
Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True) Nothing
-- Importing generates a branch
-- that is not initially connected
-- to the current branch, so allow

View file

@ -0,0 +1,23 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2024-01-18T16:18:38Z"
content="""
This would need to start with `git-annex import --from=remote`
getting a `--message` option. Which I've just implemented.
As for adding an option to `git-annex pull`, it would need to be an option
other than `--message`, because `git-annex sync` already uses `--message`
for the commit message. And since `git-annex pull` can pull from more than
one remote at a time, it seems that it would need an option that specifies
a message plus which remote to use that message for. Or the option
would need to only be used when using `git-annex pull` with a single
specified remote.
That seems like perhaps unncessary complexity, since if you want to import
a tree from a remote and specify a message, you can just use
`git-annex import` with `--message` now.
And then you can run `git-annex pull` to proceed with the rest of what it does.
Good enough?
"""]]

View file

@ -102,6 +102,11 @@ the tree of files on the remote, even when importing into a subdirectory.
`git-annex get` can later be used to download files, as desired.
The --no-content option is not supported by all special remotes.
* `--message=msg` `-m msg`
Use this option to specify a commit message for the changes that have
been made to the special remote since the last import from it.
# IMPORTING FROM A DIRECTORY
When run with a path, `git annex import` **moves** files from somewhere outside