mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	utils/version: add get_commit
Add a function to get the commit ID of the devlib repository (if running from source, e.g. via "setup.py develop").
This commit is contained in:
		
				
					committed by
					
						
						setrofim
					
				
			
			
				
	
			
			
			
						parent
						
							f1c945bb5e
						
					
				
				
					commit
					4a862d06bb
				
			
							
								
								
									
										15
									
								
								devlib/utils/version.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								devlib/utils/version.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					import os
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					from subprocess import Popen, PIPE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_commit():
 | 
				
			||||||
 | 
					    p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__),
 | 
				
			||||||
 | 
					              stdout=PIPE, stderr=PIPE)
 | 
				
			||||||
 | 
					    std, _ = p.communicate()
 | 
				
			||||||
 | 
					    p.wait()
 | 
				
			||||||
 | 
					    if p.returncode:
 | 
				
			||||||
 | 
					        return None
 | 
				
			||||||
 | 
					    if sys.version_info[0] == 3:
 | 
				
			||||||
 | 
					        return std[:8].decode(sys.stdout.encoding)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        return std[:8]
 | 
				
			||||||
		Reference in New Issue
	
	Block a user