More git wescamp fixes

This commit is contained in:
Alexander van Gessel 2011-12-05 00:51:02 +01:00
parent 32676ed2a5
commit a26bbeec75
2 changed files with 16 additions and 3 deletions

View file

@ -19,6 +19,7 @@ import urllib2
#TODO: document and log where missing
#TODO: every _execute with check_error=False is a place where more sophisticated checking should be done
class Error(Exception):
"""Base class for exceptions in this module."""
@ -55,7 +56,8 @@ class Addon(object):
Returns whether anything changed.
"""
logging.debug("Updating add-on {0}".format(self.name))
out, err = self._execute(["git", "pull"], check_error=True)
# Stuff gets printed to stderr on a checkout of a fresh (empty) repository
out, err = self._execute(["git", "pull"], check_error=False)
#TODO: make this less hacky
return len(out.split("\n")) > 2
@ -235,6 +237,16 @@ class GitHub(object):
self._clone(name, response["ssh_url"])
return self.addon(name)
def addon_exists(self, name):
"""Checks whether an add-on exists on github..
name: Name of the add-on.
Returns a bool representing the existence of the add-on.
"""
logging.debug("Checking whether add-on {0} exists".format(name))
github_list = self._github_repos_list()
return name in [repo[0] for repo in github_list]
def _absolute_path(self, name):
return os.path.join(self.directory, name)

View file

@ -164,7 +164,8 @@ if __name__ == "__main__":
svn_dir + "/" + addon)
if use_git:
github.create_addon(addon)
if not github.addon_exists(addon):
github.create_addon(addon)
else:
svn = libsvn.SVN(svn_dir)
@ -407,7 +408,7 @@ if __name__ == "__main__":
logging.error("No wescamp checkout specified. Needed for git usage.")
sys.exit(2)
try:
git_version = wescamp.split("-")[-1]
git_version = wescamp.split("-")[-1].strip("/").split("/")[-1]
except:
logging.error("Wescamp directory path does not end in a version suffix. Currently needed for git usage.")
sys.exit(2)