import: --message/-m option
authorJoey Hess <joeyh@joeyh.name>
Thu, 18 Jan 2024 16:41:44 +0000 (12:41 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 18 Jan 2024 16:41:44 +0000 (12:41 -0400)
CHANGELOG
Command/Import.hs
Command/Sync.hs
doc/bugs/Request_the_ability_to_specify_pull_commit_message/.comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment.swp [new file with mode: 0644]
doc/bugs/Request_the_ability_to_specify_pull_commit_message/comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment [new file with mode: 0644]
doc/git-annex-import.mdwn

index 5398bacdcbd09f1cd65a2ea80c44a127c52ad8c6..20278c8ba3265d5e6bfee671e1ff0d819d730016 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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
 
index b3cf4d4ad1fd7d40124298cf04ccf8623aa8fe9b..a37064eefc0d83321d2c5373639f281a13635b49 100644 (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
 
index 260740d5b50dae576113ba817c0279f2dc972f4e..c4cbb0ccd160227c72caa6717a362da90d66009c 100644 (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
diff --git a/doc/bugs/Request_the_ability_to_specify_pull_commit_message/.comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment.swp b/doc/bugs/Request_the_ability_to_specify_pull_commit_message/.comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment.swp
new file mode 100644 (file)
index 0000000..1a6dfc9
Binary files /dev/null and b/doc/bugs/Request_the_ability_to_specify_pull_commit_message/.comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment.swp differ
diff --git a/doc/bugs/Request_the_ability_to_specify_pull_commit_message/comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment b/doc/bugs/Request_the_ability_to_specify_pull_commit_message/comment_1_6d581ea36afab3829cd56d6d6b83c6f3._comment
new file mode 100644 (file)
index 0000000..db1e45a
--- /dev/null
@@ -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?
+"""]]
index 9844e239ee0e4b9b536dacae692d91dd86c3ce84..b72fae5d5fd93695adf4c5cf89c34a3400cba9ea 100644 (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