From ae34ac126fa609fb17955b02c685d7de164b4e54 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sat, 7 Sep 2013 17:19:29 +0100 Subject: git_remote_helpers: remove little used Python library When it was originally added, the git_remote_helpers library was used as part of the tests of the remote-helper interface, but since commit fc407f9 (Add new simplified git-remote-testgit, 2012-11-28) a simple shell script is used for this. A search on Ohloh [1] indicates that this library isn't used by any external projects and even the Python remote helpers in contrib/ don't use this library, so it is only used by its own test suite. Since this is the only Python library in Git, removing it will make packaging easier as the Python scripts only need to be installed for one version of Python, whereas the library should be installed for all available versions. [1] http://code.ohloh.net/search?s=%22git_remote_helpers%22 Signed-off-by: John Keeping Acked-by: Sverre Rabbelier Signed-off-by: Junio C Hamano --- git_remote_helpers/git/repo.py | 76 ------------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 git_remote_helpers/git/repo.py (limited to 'git_remote_helpers/git/repo.py') diff --git a/git_remote_helpers/git/repo.py b/git_remote_helpers/git/repo.py deleted file mode 100644 index acbf8d778..000000000 --- a/git_remote_helpers/git/repo.py +++ /dev/null @@ -1,76 +0,0 @@ -import os -import subprocess - -from git_remote_helpers.util import check_call - - -def sanitize(rev, sep='\t'): - """Converts a for-each-ref line to a name/value pair. - """ - - splitrev = rev.split(sep) - branchval = splitrev[0] - branchname = splitrev[1].strip() - if branchname.startswith("refs/heads/"): - branchname = branchname[11:] - - return branchname, branchval - -def is_remote(url): - """Checks whether the specified value is a remote url. - """ - - prefixes = ["http", "file", "git"] - - for prefix in prefixes: - if url.startswith(prefix): - return True - return False - -class GitRepo(object): - """Repo object representing a repo. - """ - - def __init__(self, path): - """Initializes a new repo at the given path. - """ - - self.path = path - self.head = None - self.revmap = {} - self.local = not is_remote(self.path) - - if(self.path.endswith('.git')): - self.gitpath = self.path - else: - self.gitpath = os.path.join(self.path, '.git') - - if self.local and not os.path.exists(self.gitpath): - os.makedirs(self.gitpath) - - def get_revs(self): - """Fetches all revs from the remote. - """ - - args = ["git", "ls-remote", self.gitpath] - path = ".cached_revs" - ofile = open(path, "w") - - check_call(args, stdout=ofile) - output = open(path).readlines() - self.revmap = dict(sanitize(i) for i in output) - if "HEAD" in self.revmap: - del self.revmap["HEAD"] - self.revs = self.revmap.keys() - ofile.close() - - def get_head(self): - """Determines the head of a local repo. - """ - - if not self.local: - return - - path = os.path.join(self.gitpath, "HEAD") - head = open(path).readline() - self.head, _ = sanitize(head, ' ') -- cgit v1.2.1