chiark / gitweb /
Easier multiline strings
[fdroidserver.git] / fdroidserver / common.py
index bf89b1d581da3013d41019e77b48dcb375325bf7..bdc6da2e5fa80e0f8ccb6d8aad336bfee9e01c9d 100644 (file)
@@ -351,7 +351,9 @@ class vcs:
                     writeback = False
                 else:
                     deleterepo = True
-                    logging.info("Repository details changed - deleting")
+                    logging.info(
+                        "Repository details for {0} changed - deleting"
+                        .format(self.local))
             else:
                 deleterepo = True
                 logging.info("Repository details missing - deleting")
@@ -434,8 +436,9 @@ class vcs_git(vcs):
                 if p.returncode != 0:
                     raise VCSException("Git fetch failed")
                 self.refreshed = True
-        # Check out the appropriate revision
-        rev = str(rev if rev else 'origin/master')
+        # origin/HEAD is the HEAD of the remote, e.g. the "default branch" on
+        # a github repo. Most of the time this is the same as origin/master.
+        rev = str(rev if rev else 'origin/HEAD')
         p = SilentPopen(['git', 'checkout', '-f', rev], cwd=self.local)
         if p.returncode != 0:
             raise VCSException("Git checkout failed")
@@ -480,9 +483,9 @@ class vcs_git(vcs):
 
     def latesttags(self, alltags, number):
         self.checkrepo()
-        p = SilentPopen(['echo "' + '\n'.join(alltags) + '" | \
-                xargs -I@ git log --format=format:"%at @%n" -1 @ | \
-                sort -n | awk \'{print $2}\''],
+        p = SilentPopen(['echo "' + '\n'.join(alltags) + '" | '
+                        + 'xargs -I@ git log --format=format:"%at @%n" -1 @ | '
+                        + 'sort -n | awk \'{print $2}\''],
                         cwd=self.local, shell=True)
         return p.stdout.splitlines()[-number:]
 
@@ -1456,7 +1459,7 @@ def scan_source(build_dir, root_dir, thisbuild):
     # buildjni=no to bypass this check)
     if (os.path.exists(os.path.join(root_dir, 'jni')) and
             not thisbuild['buildjni']):
-        logging.error('Found jni directory, but buildjni is not enabled')
+        logging.error('Found jni directory, but buildjni is not enabled. Set it to \'no\' to ignore.')
         count += 1
 
     return count
@@ -1576,7 +1579,7 @@ def SilentPopen(commands, cwd=None, shell=False):
     return FDroidPopen(commands, cwd=cwd, shell=shell, output=False)
 
 
-def FDroidPopen(commands, cwd=None, shell=False, output=False):
+def FDroidPopen(commands, cwd=None, shell=False, output=True):
     """
     Run a command and capture the possibly huge output.
 
@@ -1585,11 +1588,10 @@ def FDroidPopen(commands, cwd=None, shell=False, output=False):
     :returns: A PopenResult.
     """
 
-    if output:
-        if cwd:
-            cwd = os.path.normpath(cwd)
-            logging.info("Directory: %s" % cwd)
-        logging.info("> %s" % ' '.join(commands))
+    if cwd:
+        cwd = os.path.normpath(cwd)
+        logging.debug("Directory: %s" % cwd)
+    logging.debug("> %s" % ' '.join(commands))
 
     result = PopenResult()
     p = subprocess.Popen(commands, cwd=cwd, shell=shell,
@@ -1632,6 +1634,8 @@ def remove_signing_keys(build_dir):
             with open(path, "r") as o:
                 lines = o.readlines()
 
+            changed = False
+
             opened = 0
             with open(path, "w") as o:
                 for line in lines:
@@ -1644,16 +1648,19 @@ def remove_signing_keys(build_dir):
                         continue
 
                     if signing_configs.match(line):
+                        changed = True
                         opened += 1
                         continue
 
                     if any(s.match(line) for s in line_matches):
+                        changed = True
                         continue
 
                     if opened == 0:
                         o.write(line)
 
-            logging.info("Cleaned build.gradle of keysigning configs at %s" % path)
+            if changed:
+                logging.info("Cleaned build.gradle of keysigning configs at %s" % path)
 
         for propfile in [
                 'project.properties',
@@ -1667,15 +1674,18 @@ def remove_signing_keys(build_dir):
                 with open(path, "r") as o:
                     lines = o.readlines()
 
+                changed = False
+
                 with open(path, "w") as o:
                     for line in lines:
-                        if line.startswith('key.store'):
-                            continue
-                        if line.startswith('key.alias'):
+                        if any(line.startswith(s) for s in ('key.store', 'key.alias')):
+                            changed = True
                             continue
+
                         o.write(line)
 
-                logging.info("Cleaned %s of keysigning configs at %s" % (propfile, path))
+                if changed:
+                    logging.info("Cleaned %s of keysigning configs at %s" % (propfile, path))
 
 
 def replace_config_vars(cmd):