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.
This commit is contained in:
		
					parent
					
						
							
								07eec0b396
							
						
					
				
			
			
				commit
				
					
						f5b830e07c
					
				
			
		
					 5 changed files with 33 additions and 6 deletions
				
			
		|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
							
								
								
									
										1
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							|  | @ -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 <id@joeyh.name>  Fri, 06 Feb 2015 13:57:08 -0400 | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,3 +8,8 @@ Could not commit staged changes. | |||
| </pre> | ||||
| 
 | ||||
| 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]]  | ||||
|  |  | |||
|  | @ -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. | ||||
| """]] | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Joey Hess
				Joey Hess