git-annex assist

assist: New command, which is the same as git-annex sync but with
new files added and content transferred by default.

(Also this fixes another reversion in git-annex sync,
--commit --no-commit, and --message were not enabled, oops.)

See added comment for why git-annex assist does commit staged
changes elsewhere in the work tree, but only adds files under
the cwd.

Note that it does not support --no-commit, --no-push, --no-pull
like sync does. My thinking is, why should it? If you want that
level of control, use git commit, git annex push, git annex pull.
Sync only got those options because pull and push were not split
out.

Sponsored-by: k0ld on Patreon
This commit is contained in:
Joey Hess 2023-05-18 14:37:29 -04:00
parent 80e9a655f8
commit e955912ad0
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
16 changed files with 224 additions and 47 deletions

43
Command/Assist.hs Normal file
View file

@ -0,0 +1,43 @@
{- git-annex command
-
- Copyright 2023 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Command.Assist (cmd) where
import Command
import qualified Command.Sync
import qualified Command.Add
import Annex.CheckIgnore
cmd :: Command
cmd = withAnnexOptions [jobsOption, backendOption] $
command "assist" SectionCommon
"add files and sync changes with remotes"
(paramRepeating paramRemote)
(myseek <--< Command.Sync.optParser Command.Sync.AssistMode)
myseek :: Command.Sync.SyncOptions -> CommandSeek
myseek o = startConcurrency transferStages $ do
-- Run before prepMerge so it adds only files in the current
-- directory and below, not new files elsewhere in the working
-- tree.
Command.Add.seek Command.Add.AddOptions
{ Command.Add.addThese = []
, Command.Add.batchOption = NoBatch
, Command.Add.updateOnly = False
, Command.Add.largeFilesOverride = Nothing
, Command.Add.checkGitIgnoreOption = CheckGitIgnore (False)
, Command.Add.dryRunOption = DryRun False
}
Command.Sync.prepMerge
Command.Sync.seek' o'
where
o'
| Command.Sync.contentOption o == Nothing
&& Command.Sync.noContentOption o == Nothing =
o { Command.Sync.contentOption = Just True }
| otherwise = o