Exemple #1
0
Fichier : git.py Projet : lcary/nbd
 def diff_no_index(self, file_a, file_b, options=None):
     args = [
         self._git, '--no-pager', 'diff', '--exit-code', '--no-index',
         '--color=always'
     ]
     if options is not None:
         args.extend(options)
     args.extend([file_a, file_b])
     echo(self._git, ANSI_LIGHT_RED, " ".join(args))
     subprocess.call(args)
Exemple #2
0
    def get_diff(self, git_diff_options):
        with mktempdir() as tempdir:
            # create old and new directories
            old_dir = ospath.join(tempdir, 'old')
            new_dir = ospath.join(tempdir, 'new')
            dir_util.mkpath(old_dir)
            dir_util.mkpath(new_dir)

            # # export data from notebooks in git repo and notebooks in tempdir
            self._export_old_and_new_notebooks(tempdir, old_dir, new_dir)

            # show git diff of exported data within tempdir
            msg = "git diff output below (no output == no diff)"
            echo(PKG_NAME, ANSI_LIGHT_GREEN, msg)
            self._git_cmd.diff_no_index(old_dir,
                                        new_dir,
                                        options=git_diff_options)
Exemple #3
0
    def retreive_renamed_file(self, file_data):
        """
    Return the filepath of the previous filename if it was renamed.
    Otherwise, throw exception.
    """
        input_filepath = file_data.input_filepath
        renamed_file_lines = self._git_diff_renamed_files(file_data.commit)

        for line in renamed_file_lines:
            old_filepath = self._parse_previous_filename(line, input_filepath)
            if old_filepath is not None:
                msg = 'git shows renamed file:\n{}'.format(line)
                echo('git', ANSI_LIGHT_RED, msg, lvl=logger.info)
                return old_filepath

        msg = 'Unable to detect renamed version of file: {}'.format(
            input_filepath)
        raise self.RenamedFileNotFound(msg)
Exemple #4
0
Fichier : git.py Projet : lcary/nbd
 def diff_name_status(self, commit):
     args = [self._git, 'diff', commit, '--name-status']
     echo(self._git, ANSI_LIGHT_RED, " ".join(args))
     return subprocess.check_output(args)
Exemple #5
0
Fichier : git.py Projet : lcary/nbd
 def show(self, filepath, commit=HEAD):
     args = [self._git, 'show', '{}:{}'.format(commit, filepath)]
     echo(self._git, ANSI_LIGHT_RED, " ".join(args))
     return subprocess.check_output(args)
Exemple #6
0
Fichier : git.py Projet : lcary/nbd
 def rev_parse_show_toplevel(self):
     args = [self._git, 'rev-parse', '--show-toplevel']
     echo(self._git, ANSI_LIGHT_RED, " ".join(args))
     output = subprocess.check_output(args)
     decoded = output.decode(DEFAULT_ENCODING)
     return decoded.strip('\n')