Пример #1
0
 def _get_annotation(self, name):
     result = runext.run_cmd(["git", "rev-parse", name])
     result = runext.run_cmd(
         ["git", "cat-file", "-p",
          result.stdout.strip()])
     if result.stdout.startswith("object"):
         cat_lines = result.stdout.splitlines()
         return cat_lines[5] if len(cat_lines) > 5 else ""
     return ""
Пример #2
0
 def __getattr__(attr_name):
     if attr_name == "is_available":
         try:
             return runext.run_cmd(["git", "version"]).is_ok
         except OSError as edata:
             if edata.errno == errno.ENOENT:
                 return False
             else:
                 raise
     if attr_name == "in_valid_pgnd":
         return runext.run_cmd(["git", "config", "--local", "-l"]).is_ok
     raise AttributeError(attr_name)
Пример #3
0
 def do_import_patch(cls, patch_filepath):
     ok_to_import, msg = cls.is_ready_for_import()
     if not ok_to_import:
         return CmdResult.error(stderr=msg)
     epatch = patchlib.Patch.parse_text_file(patch_filepath)
     description = epatch.get_description()
     if not description:
         return CmdResult.error(stderr="Empty description")
     result = runext.run_cmd(["git", "apply", patch_filepath])
     if not result.is_less_than_error:
         return result
     result = runext.run_cmd(["git", "add"] + epatch.get_file_paths(1))
     if not result.is_less_than_error:
         return result
     return runext.run_cmd(["git", "commit", "-q", "-m", description])
Пример #4
0
 def dir_is_in_valid_pgnd(dir_path=None):
     if dir_path:
         orig_dir_path = os.getcwd()
         os.chdir(dir_path)
     result = runext.run_cmd(["git", "config", "--local", "-l"])
     if dir_path:
         os.chdir(orig_dir_path)
     return result.is_ok
Пример #5
0
 def get_commit_message(commit=None):
     cmd = ["git", "log", "-n", "1", "--pretty=format:%s%n%n%b"]
     if commit:
         cmd.append(commit)
     result = runext.run_cmd(cmd)
     if result.is_ok:
         return result.stdout
     return None
Пример #6
0
 def get_playground_root():
     if not runext.run_cmd(["git", "config", "--local", "-l"]).is_ok:
         return None
     dirpath = os.getcwd()
     while True:
         if os.path.isdir(os.path.join(dirpath, ".git")):
             return dirpath
         else:
             dirpath, basename = os.path.split(dirpath)
             if not basename:
                 break
     return None
Пример #7
0
 def get_commit_show(commit):
     cmd = ["git", "show", commit]
     result = runext.run_cmd(cmd)
     if result.is_ok:
         return result.stdout
     return None