mirror of
				https://github.com/powerline/powerline.git
				synced 2025-10-31 11:34:53 +01:00 
			
		
		
		
	provide stash counter
Some version control systems have an area where changes can be stored as temporary work in progress instead publishing them to the history. This segment is intended to display their count, reminding the developer about open ends in the current repository. The underlying implementation is VCS-specific and has to be provided by the respective library module.
This commit is contained in:
		
							parent
							
								
									3bcd0ec547
								
							
						
					
					
						commit
						c9ca8e06d1
					
				| @ -56,3 +56,34 @@ branch = with_docstring(BranchSegment(), | ||||
| 
 | ||||
| Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. | ||||
| ''') | ||||
| 
 | ||||
| 
 | ||||
| @requires_filesystem_watcher | ||||
| @requires_segment_info | ||||
| class StashSegment(Segment): | ||||
| 	divider_highlight_group = None | ||||
| 
 | ||||
| 	@staticmethod | ||||
| 	def get_directory(segment_info): | ||||
| 		return segment_info['getcwd']() | ||||
| 
 | ||||
| 	def __call__(self, pl, segment_info, create_watcher): | ||||
| 		name = self.get_directory(segment_info) | ||||
| 		if name: | ||||
| 			repo = guess(path=name, create_watcher=create_watcher) | ||||
| 			if repo is not None: | ||||
| 				stash = getattr(repo, 'stash', None) | ||||
| 				if stash: | ||||
| 					stashes = stash() | ||||
| 					if stashes: | ||||
| 						return [{ | ||||
| 							'contents': str(stashes), | ||||
| 							'highlight_groups': ['stash'], | ||||
| 							'divider_highlight_group': self.divider_highlight_group | ||||
| 						}] | ||||
| 
 | ||||
| stash = with_docstring(StashSegment(), | ||||
| '''Return the number of current VCS stash entries, if any. | ||||
| 
 | ||||
| Highlight groups used: ``stash``. | ||||
| ''') | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user