From 0dfcca521027baef75953b644aaf71dc58bec80b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 11 Feb 2015 13:33:55 -0400 Subject: sync, assistant: Include repository name in head branch commit message. Note that while the assistant detects changes made to remote names, I left the commit message fixed rather than calculating it after every commit. It doesn't seem worth the CPU to do the latter. --- Assistant/Threads/Committer.hs | 9 +++++---- Command/Sync.hs | 13 +++++++++++-- debian/changelog | 1 + doc/todo/do_not_commit_with_empty_messages.mdwn | 5 +++++ .../comment_1_3cff336e58c26eafade4a37b0c9e0634._comment | 11 +++++++++++ 5 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 doc/todo/do_not_commit_with_empty_messages/comment_1_3cff336e58c26eafade4a37b0c9e0634._comment diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs index 3f8debdc2..8cf6da2d2 100644 --- a/Assistant/Threads/Committer.hs +++ b/Assistant/Threads/Committer.hs @@ -50,6 +50,7 @@ commitThread = namedThread "Committer" $ do delayadd <- liftAnnex $ maybe delayaddDefault (return . Just . Seconds) =<< annexDelayAdd <$> Annex.getGitConfig + msg <- liftAnnex Command.Sync.commitMsg waitChangeTime $ \(changes, time) -> do readychanges <- handleAdds havelsof delayadd changes if shouldCommit False time (length readychanges) readychanges @@ -60,7 +61,7 @@ commitThread = namedThread "Committer" $ do , "changes" ] void $ alertWhile commitAlert $ - liftAnnex commitStaged + liftAnnex $ commitStaged msg recordCommit let numchanges = length readychanges mapM_ checkChangeContent readychanges @@ -212,15 +213,15 @@ shouldCommit scanning now len changes recentchanges = filter thissecond changes timeDelta c = now `diffUTCTime` changeTime c -commitStaged :: Annex Bool -commitStaged = do +commitStaged :: String -> Annex Bool +commitStaged msg = do {- This could fail if there's another commit being made by - something else. -} v <- tryNonAsync Annex.Queue.flush case v of Left _ -> return False Right _ -> do - ok <- Command.Sync.commitStaged Git.Branch.AutomaticCommit "" + ok <- Command.Sync.commitStaged Git.Branch.AutomaticCommit msg when ok $ Command.Sync.updateSyncBranch =<< inRepo Git.Branch.current return ok diff --git a/Command/Sync.hs b/Command/Sync.hs index 65a025606..ddd4e0309 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -12,6 +12,7 @@ module Command.Sync ( mergeLocal, mergeRemote, commitStaged, + commitMsg, pushBranch, updateBranch, syncBranch, @@ -41,10 +42,12 @@ import qualified Command.Move import Logs.Location import Annex.Drop import Annex.UUID +import Logs.UUID import Annex.AutoMerge import Annex.Ssh import Control.Concurrent.MVar +import qualified Data.Map as M cmd :: [Command] cmd = [withOptions syncOptions $ @@ -145,8 +148,8 @@ syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted ) commit :: CommandStart commit = next $ next $ do - commitmessage <- fromMaybe "git-annex automatic sync" - <$> Annex.getField (optionName messageOption) + commitmessage <- maybe commitMsg return + =<< Annex.getField (optionName messageOption) showStart "commit" "" Annex.Branch.commit "update" ifM isDirect @@ -163,6 +166,12 @@ commit = next $ next $ do return True ) +commitMsg :: Annex String +commitMsg = do + u <- getUUID + m <- uuidMap + return $ "git-annex in " ++ fromMaybe "unknown" (M.lookup u m) + commitStaged :: Git.Branch.CommitMode -> String -> Annex Bool commitStaged commitmode commitmessage = go =<< inRepo Git.Branch.currentUnsafe where diff --git a/debian/changelog b/debian/changelog index 5ae18df12..92c702b41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,7 @@ git-annex (5.20150206) UNRELEASED; urgency=medium * metadata: When setting metadata, do not recurse into directories by default, since that can be surprising behavior and difficult to recover from. The old behavior is available by using --force. + * sync, assistant: Include repository name in head branch commit message. -- Joey Hess Fri, 06 Feb 2015 13:57:08 -0400 diff --git a/doc/todo/do_not_commit_with_empty_messages.mdwn b/doc/todo/do_not_commit_with_empty_messages.mdwn index d835bfd79..3c6c8415a 100644 --- a/doc/todo/do_not_commit_with_empty_messages.mdwn +++ b/doc/todo/do_not_commit_with_empty_messages.mdwn @@ -8,3 +8,8 @@ Could not commit staged changes. This was trying to fix [[a broken merge|forum/canceling_wrong_repository_merge/]]... --[[anarcat]] + +> While I think it's silly to use empty dummy commit messages when there +> is nothing of value to say about the commit, I guess I can add value +> by putting in the name of the repository where the commit was made. So, +> [[done]] --[[Joey]] diff --git a/doc/todo/do_not_commit_with_empty_messages/comment_1_3cff336e58c26eafade4a37b0c9e0634._comment b/doc/todo/do_not_commit_with_empty_messages/comment_1_3cff336e58c26eafade4a37b0c9e0634._comment new file mode 100644 index 000000000..c2cd7833f --- /dev/null +++ b/doc/todo/do_not_commit_with_empty_messages/comment_1_3cff336e58c26eafade4a37b0c9e0634._comment @@ -0,0 +1,11 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2015-02-11T17:15:04Z" + content=""" +It's completely legal for git commits to have empty commit messages. Why +would rebase care? Seems like a bug in rebase. + +Note that only the git-annex assistant currently uses empty commit +messages. +"""]] -- cgit v1.2.3