Steve Losh avatar Steve Losh committed d5268ca

guts: Mention the currently installed version in the info command.

Comments (0)

Files changed (3)

lib/gorilla/guts/cli.py

             
             shelf = Shelf(card)
             
-            download_status = 'yes (vcs: %s)' % shelf.vcs if shelf.present else 'no'
-            install_status = 'yes' if shelf.installed else 'no'
+            d_st = 'yes (vcs: %s)' % shelf.vcs if shelf.present else 'no'
+            i_st = 'yes (version: %s)' % shelf.current_version if shelf.installed else 'no'
             
-            ui.write('\ndownloaded: %s\n' % download_status)
-            ui.write('installed:  %s\n\n' % install_status)
+            ui.write('\ndownloaded: %s\n' % d_st)
+            ui.write('installed:  %s\n\n' % i_st)
             
             shelf = Shelf(card)
             if shelf.present:

lib/gorilla/guts/repo.py

         command = self.command + ['tags', '--quiet']
         proc = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE)
         
-        return proc.communicate()[0].splitlines()
+        output = proc.communicate()[0]
+        return [t.strip() for t in output.splitlines() if t.strip() != 'tip']
+    
+    @property
+    def current_tags(self):
+        command = self.command + ['parents', '--template', '{tags}']
+        proc = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE)
+        
+        output = proc.communicate()[0]
+        tags = output.split(' ') + ['latest']
+        return [t.strip() for t in tags if t.strip() != 'tip']
     
 
 class StaticRepo(object):
         
         shutil.copytree(source, path)
     
+    
     @property
     def tags(self):
         return self.sources.keys()
     
+    
+    @property
+    def current_tags(self):
+        return None
+    

lib/gorilla/guts/shelf.py

         tags.insert(0, 'latest')
         return tags
     
+    
+    @property
+    def current_version(self):
+        tags = self.repo.current_tags
+        
+        # TODO: Handle this for static repos.
+        if not tags:
+            return None
+        
+        version_tags = filter(lambda t: t in self.versions, tags)
+        return version_tags[0]
+    
+    
     def grab(self):
         """Download the latest version of the package (clone if necessary).
         
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.