added annex.commitmessage

Added annex.commitmessage config that can specify a commit message for the
git-annex branch instead of the usual "update".

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2018-08-02 14:06:06 -04:00
parent 5c3864b326
commit ae11394efa
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
14 changed files with 38 additions and 15 deletions

View file

@ -1,6 +1,6 @@
{- management of the git-annex branch {- management of the git-annex branch
- -
- Copyright 2011-2017 Joey Hess <id@joeyh.name> - Copyright 2011-2018 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU GPL version 3 or higher. - Licensed under the GNU GPL version 3 or higher.
-} -}
@ -19,6 +19,7 @@ module Annex.Branch (
getHistorical, getHistorical,
change, change,
maybeChange, maybeChange,
commitMessage,
commit, commit,
forceCommit, forceCommit,
getBranch, getBranch,
@ -51,7 +52,7 @@ import qualified Git.Tree
import Git.LsTree (lsTreeParams) import Git.LsTree (lsTreeParams)
import qualified Git.HashObject import qualified Git.HashObject
import Annex.HashObject import Annex.HashObject
import Git.Types import Git.Types (Ref(..), fromRef, RefDate, TreeItemType(..))
import Git.FilePath import Git.FilePath
import Annex.CatFile import Annex.CatFile
import Annex.Perms import Annex.Perms
@ -177,9 +178,9 @@ updateTo' pairs = do
go branchref dirty tomerge jl = withIndex $ do go branchref dirty tomerge jl = withIndex $ do
let (refs, branches) = unzip tomerge let (refs, branches) = unzip tomerge
cleanjournal <- if dirty then stageJournal jl else return noop cleanjournal <- if dirty then stageJournal jl else return noop
let merge_desc = if null tomerge merge_desc <- if null tomerge
then "update" then commitMessage
else "merging " ++ else return $ "merging " ++
unwords (map Git.Ref.describe branches) ++ unwords (map Git.Ref.describe branches) ++
" into " ++ fromRef name " into " ++ fromRef name
localtransitions <- parseTransitionsStrictly "local" localtransitions <- parseTransitionsStrictly "local"
@ -259,6 +260,11 @@ maybeChange file f = lockJournal $ \jl -> do
set :: JournalLocked -> FilePath -> String -> Annex () set :: JournalLocked -> FilePath -> String -> Annex ()
set = setJournalFile set = setJournalFile
{- Commit message used when making a commit of whatever data has changed
- to the git-annex brach. -}
commitMessage :: Annex String
commitMessage = fromMaybe "update" . annexCommitMessage <$> Annex.getGitConfig
{- Stages the journal, and commits staged changes to the branch. -} {- Stages the journal, and commits staged changes to the branch. -}
commit :: String -> Annex () commit :: String -> Annex ()
commit = whenM journalDirty . forceCommit commit = whenM journalDirty . forceCommit

View file

@ -975,7 +975,7 @@ saveState nocommit = doSideAction $ do
Annex.Queue.flush Annex.Queue.flush
unless nocommit $ unless nocommit $
whenM (annexAlwaysCommit <$> Annex.getGitConfig) $ whenM (annexAlwaysCommit <$> Annex.getGitConfig) $
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
{- Downloads content from any of a list of urls. -} {- Downloads content from any of a list of urls. -}
downloadUrl :: Key -> MeterUpdate -> [Url.URLString] -> FilePath -> Annex Bool downloadUrl :: Key -> MeterUpdate -> [Url.URLString] -> FilePath -> Annex Bool

View file

@ -82,7 +82,7 @@ initRepo' desc mgroup = unlessM isInitialized $ do
maybe noop (defaultStandardGroup u) mgroup maybe noop (defaultStandardGroup u) mgroup
{- Ensure branch gets committed right away so it is {- Ensure branch gets committed right away so it is
- available for merging immediately. -} - available for merging immediately. -}
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
{- Checks if a git repo exists at a location. -} {- Checks if a git repo exists at a location. -}
probeRepoExists :: FilePath -> IO Bool probeRepoExists :: FilePath -> IO Bool

View file

@ -124,7 +124,7 @@ pushToRemotes remotes = do
pushToRemotes' :: UTCTime -> [Remote] -> Assistant [Remote] pushToRemotes' :: UTCTime -> [Remote] -> Assistant [Remote]
pushToRemotes' now remotes = do pushToRemotes' now remotes = do
(g, branch, u) <- liftAnnex $ do (g, branch, u) <- liftAnnex $ do
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
(,,) (,,)
<$> gitRepo <$> gitRepo
<*> join Command.Sync.getCurrBranch <*> join Command.Sync.getCurrBranch

View file

@ -138,7 +138,7 @@ postConfigFsckR = page "Consistency checks" (Just Configuration) $ do
changeSchedule :: Handler () -> Handler Html changeSchedule :: Handler () -> Handler Html
changeSchedule a = do changeSchedule a = do
a a
liftAnnex $ Annex.Branch.commit "update" liftAnnex $ Annex.Branch.commit =<< Annex.Branch.commitMessage
redirect ConfigFsckR redirect ConfigFsckR
getRemoveActivityR :: UUID -> ScheduledActivity -> Handler Html getRemoveActivityR :: UUID -> ScheduledActivity -> Handler Html

View file

@ -6,6 +6,8 @@ git-annex (6.20180720) UNRELEASED; urgency=medium
* Added remote.name.annex-speculate-present config that can be used to * Added remote.name.annex-speculate-present config that can be used to
make cache remotes. make cache remotes.
* Added --accessedwithin matching option. * Added --accessedwithin matching option.
* Added annex.commitmessage config that can specify a commit message
for the git-annex branch instead of the usual "update".
-- Joey Hess <id@joeyh.name> Tue, 31 Jul 2018 12:14:11 -0400 -- Joey Hess <id@joeyh.name> Tue, 31 Jul 2018 12:14:11 -0400

View file

@ -21,7 +21,7 @@ seek = withNothing start
start :: CommandStart start :: CommandStart
start = next $ next $ do start = next $ next $ do
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
_ <- runhook <=< inRepo $ Git.hookPath "annex-content" _ <- runhook <=< inRepo $ Git.hookPath "annex-content"
return True return True
where where

View file

@ -27,7 +27,7 @@ mergeBranch = do
next $ do next $ do
Annex.Branch.update Annex.Branch.update
-- commit explicitly, in case no remote branches were merged -- commit explicitly, in case no remote branches were merged
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
next $ return True next $ return True
mergeSynced :: CommandStart mergeSynced :: CommandStart

View file

@ -301,7 +301,7 @@ commit :: SyncOptions -> CommandStart
commit o = stopUnless shouldcommit $ next $ next $ do commit o = stopUnless shouldcommit $ next $ next $ do
commitmessage <- maybe commitMsg return (messageOption o) commitmessage <- maybe commitMsg return (messageOption o)
showStart' "commit" Nothing showStart' "commit" Nothing
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
ifM isDirect ifM isDirect
( do ( do
void stageDirect void stageDirect
@ -544,7 +544,7 @@ pushBranch remote branch g = directpush `after` annexpush `after` syncpush
commitAnnex :: CommandStart commitAnnex :: CommandStart
commitAnnex = do commitAnnex = do
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
stop stop
mergeAnnex :: CommandStart mergeAnnex :: CommandStart

View file

@ -78,7 +78,7 @@ knownUrls = do
- any journaled changes are reflected in it, since we're going - any journaled changes are reflected in it, since we're going
- to query its index directly. -} - to query its index directly. -}
Annex.Branch.update Annex.Branch.update
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
Annex.Branch.withIndex $ do Annex.Branch.withIndex $ do
top <- fromRepo Git.repoPath top <- fromRepo Git.repoPath
(l, cleanup) <- inRepo $ Git.LsFiles.stagedDetails [top] (l, cleanup) <- inRepo $ Git.LsFiles.stagedDetails [top]

View file

@ -728,7 +728,7 @@ commitOnCleanup repo r a = go `after` a
cleanup cleanup
| not $ Git.repoIsUrl repo = onLocalFast repo r $ | not $ Git.repoIsUrl repo = onLocalFast repo r $
doQuietSideAction $ doQuietSideAction $
Annex.Branch.commit "update" Annex.Branch.commit =<< Annex.Branch.commitMessage
| otherwise = void $ do | otherwise = void $ do
Just (shellcmd, shellparams) <- Just (shellcmd, shellparams) <-
Ssh.git_annex_shell NoConsumeStdin Ssh.git_annex_shell NoConsumeStdin

View file

@ -62,6 +62,7 @@ data GitConfig = GitConfig
, annexBloomAccuracy :: Maybe Int , annexBloomAccuracy :: Maybe Int
, annexSshCaching :: Maybe Bool , annexSshCaching :: Maybe Bool
, annexAlwaysCommit :: Bool , annexAlwaysCommit :: Bool
, annexCommitMessage :: Maybe String
, annexMergeAnnexBranches :: Bool , annexMergeAnnexBranches :: Bool
, annexDelayAdd :: Maybe Int , annexDelayAdd :: Maybe Int
, annexHttpHeaders :: [String] , annexHttpHeaders :: [String]
@ -123,6 +124,7 @@ extractGitConfig r = GitConfig
, annexBloomAccuracy = getmayberead (annex "bloomaccuracy") , annexBloomAccuracy = getmayberead (annex "bloomaccuracy")
, annexSshCaching = getmaybebool (annex "sshcaching") , annexSshCaching = getmaybebool (annex "sshcaching")
, annexAlwaysCommit = getbool (annex "alwayscommit") True , annexAlwaysCommit = getbool (annex "alwayscommit") True
, annexCommitMessage = getmaybe (annex "commitmessage")
, annexMergeAnnexBranches = getbool (annex "merge-annex-branches") True , annexMergeAnnexBranches = getbool (annex "merge-annex-branches") True
, annexDelayAdd = getmayberead (annex "delayadd") , annexDelayAdd = getmayberead (annex "delayadd")
, annexHttpHeaders = getlist (annex "http-headers") , annexHttpHeaders = getlist (annex "http-headers")

View file

@ -974,6 +974,17 @@ Here are all the supported configuration settings.
since it could garbage collect objects that are staged in git-annex's since it could garbage collect objects that are staged in git-annex's
index but not yet committed. index but not yet committed.
* `annex.commitmessage`
When git-annex updates the git-annex branch, it usually makes up
its own commit message ("update"), since users rarely look at or
care about changes to that branch. If you do care, you can
specify this setting by running commands with
`-c annex.commitmessage=whatever`
This works well in combination with annex.alwayscommit=false,
to gather up a set of changes and commit them with a message you specify.
* `annex.merge-annex-branches` * `annex.merge-annex-branches`
By default, git-annex branches that have been pulled from remotes By default, git-annex branches that have been pulled from remotes

View file

@ -1,3 +1,5 @@
ATM many commit messages in git-annex branch are just an "update". But I wondered if it could be relatively simple to implement to be able to provide a custom commit message, e.g. by defining some environment variable (e.g. GIT_ANNEX_UPDATE_MESSAGE) during whatever process is initiating the actual commit? sure thing there could be cases whenever multiple processes "contributed" to the changes which are finally "flushed" by committing, but imho it could provide a good way to annotate changes within git-annex branch at least to some degree. E.g. I could use "update: added URLs to the files for datalad-archives remote" ;) ATM many commit messages in git-annex branch are just an "update". But I wondered if it could be relatively simple to implement to be able to provide a custom commit message, e.g. by defining some environment variable (e.g. GIT_ANNEX_UPDATE_MESSAGE) during whatever process is initiating the actual commit? sure thing there could be cases whenever multiple processes "contributed" to the changes which are finally "flushed" by committing, but imho it could provide a good way to annotate changes within git-annex branch at least to some degree. E.g. I could use "update: added URLs to the files for datalad-archives remote" ;)
[[!meta author=yoh]] [[!meta author=yoh]]
> [[done]] as annex.commitmessage config. --[[Joey]]