Skip to content

Instantly share code, notes, and snippets.

@joeymink
Created September 20, 2013 01:57
Show Gist options
  • Save joeymink/6632417 to your computer and use it in GitHub Desktop.
Save joeymink/6632417 to your computer and use it in GitHub Desktop.
Find location of a git repo with the given name from SourceTree bookmarks on OSX
import subprocess
import os
import re
repo_folder_name='repo_name'
home = os.environ['HOME']
p = subprocess.Popen(['plutil', '-convert', 'xml1', '-o', '-', '--', "%s/Library/Application Support/SourceTree/browser.plist" % home],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
matchObj = re.search("<string>/.*/%s</string>" % repo_folder_name, out)
if matchObj:
repo_loc = matchObj.group().replace("<string>", "")
repo_loc = repo_loc.replace("</string>", "")
repo_loc = repo_loc.strip()
print repo_loc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment