Merge "Poll manage projects config fetches."
diff --git a/jeepyb/cmd/manage_projects.py b/jeepyb/cmd/manage_projects.py
index 230e274..cd44559 100644
--- a/jeepyb/cmd/manage_projects.py
+++ b/jeepyb/cmd/manage_projects.py
@@ -76,8 +76,8 @@
p = subprocess.Popen(cmd_list, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, env=newenv)
(out, nothing) = p.communicate()
- log.debug("Return code: %s" % p.returncode)
- log.debug("Command said: %s" % out.strip())
+ log.info("Return code: %s" % p.returncode)
+ log.info("Command said: %s" % out.strip())
if status:
return (p.returncode, out.strip())
return out.strip()
@@ -381,26 +381,32 @@
def update_local_copy(repo_path, track_upstream, git_opts, ssh_env):
- # If we're configured to track upstream but the repo
- # does not have an upstream remote, add one
- if (track_upstream and
- 'upstream' not in git_command_output(
- repo_path, 'remote')[1]):
- git_command(
- repo_path,
- "remote add upstream %(upstream)s" % git_opts)
+ has_upstream_remote = (
+ 'upstream' in git_command_output(repo_path, 'remote')[1])
+ if track_upstream:
+ # If we're configured to track upstream but the repo
+ # does not have an upstream remote, add one
+ if not has_upstream_remote:
+ git_command(
+ repo_path,
+ "remote add upstream %(upstream)s" % git_opts)
- # If we're configured to track upstream, make sure that
- # the upstream URL matches the config
+ # If we're configured to track upstream, make sure that
+ # the upstream URL matches the config
+ else:
+ git_command(
+ repo_path,
+ "remote set-url upstream %(upstream)s" % git_opts)
+
+ # Now that we have any upstreams configured, fetch all of the refs
+ # we might need, pruning remote branches that no longer exist
+ git_command(
+ repo_path, "remote update --prune", env=ssh_env)
else:
- git_command(
- repo_path,
- "remote set-url upstream %(upstream)s" % git_opts)
-
- # Now that we have any upstreams configured, fetch all of the refs
- # we might need, pruning remote branches that no longer exist
- git_command(
- repo_path, "remote update --prune", env=ssh_env)
+ # If we are not tracking upstream, then we do not need
+ # an upstream remote configured
+ if has_upstream_remote:
+ git_command(repo_path, "remote rm upstream")
# TODO(mordred): This is here so that later we can
# inspect the master branch for meta-info
@@ -425,12 +431,12 @@
# a local branch of, optionally prefixed with the
# upstream prefix value
for branch in git_command_output(
- repo_path, "branch -a")[1].split():
+ repo_path, "branch -a")[1].split('\n'):
if not branch.strip().startswith("remotes/upstream"):
continue
if "->" in branch:
continue
- local_branch = branch[len('remotes/upstream/'):]
+ local_branch = branch.split()[0][len('remotes/upstream/'):]
if upstream_prefix:
local_branch = "%s/%s" % (
upstream_prefix, local_branch)
@@ -523,6 +529,8 @@
parser = argparse.ArgumentParser(description='Manage projects')
parser.add_argument('-v', dest='verbose', action='store_true',
help='verbose output')
+ parser.add_argument('-d', dest='debug', action='store_true',
+ help='debug output')
parser.add_argument('--nocleanup', action='store_true',
help='do not remove temp directories')
parser.add_argument('projects', metavar='project', nargs='*',
@@ -530,6 +538,8 @@
args = parser.parse_args()
if args.verbose:
+ logging.basicConfig(level=logging.INFO)
+ elif args.debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.ERROR)
diff --git a/jeepyb/cmd/welcome_message.py b/jeepyb/cmd/welcome_message.py
index b791088..3536769 100644
--- a/jeepyb/cmd/welcome_message.py
+++ b/jeepyb/cmd/welcome_message.py
@@ -58,7 +58,7 @@
cursor.execute(query, searchkey)
data = cursor.fetchone()
if data:
- if data[0] == "1":
+ if data[0] == 1:
logger.info('We found a newbie: %s', uploader)
return True
else: