Create a git stat from changes between this commit and its first parent
        or from all changes done if this is the very first commit.

        :return: git.Stats
769195
def stats(self):
        """"""
        if not self.parents:
            text = self.repo.git.diff_tree(self.hexsha, '--', numstat=True, root=True)
            text2 = ""
            for line in text.splitlines()[1:]:
                (insertions, deletions, filename) = line.split("\t")
                text2 += "%s\t%s\t%s\n" % (insertions, deletions, filename)
            text = text2
        else:
            text = self.repo.git.diff(self.parents[0].hexsha, self.hexsha, '--', numstat=True)
        return Stats._list_from_string(self.repo, text)
1194717
def get_commits(self, since_sha=None):
        
        assert self.tempdir

        cmd = ['git', 'log', '--first-parent', '--reverse', COMMIT_FORMAT]
        if since_sha:
            commits = [self.get_commit(since_sha)]
            cmd.append('{}..HEAD'.format(since_sha))
        else:
            commits = []
            cmd.append('HEAD')

        output = cmd_output(*cmd, cwd=self.tempdir)

        for sha, date in chunk_iter(output.splitlines(), 2):
            commits.append(Commit(sha, int(date)))

        return commits
1351338
def get_revision():
	
	git_bin = smoke_zephyr.utilities.which('git')
	if not git_bin:
		return None
	proc_h = subprocess.Popen(
		(git_bin, 'rev-parse', 'HEAD'),
		stdout=subprocess.PIPE,
		stderr=subprocess.PIPE,
		close_fds=True,
		cwd=os.path.dirname(os.path.abspath(__file__))
	)
	rev = proc_h.stdout.read().strip()
	proc_h.wait()
	if not len(rev):
		return None
	return rev.decode('utf-8')
1049241
def get_git_changeset():
    """"""
    git_log = Popen(
        'git log --pretty=format:%ct --quiet -1 HEAD',
        stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
    timestamp = git_log.communicate()[0]
    try:
        timestamp = datetime.utcfromtimestamp(int(timestamp))
    except ValueError:
        return None
    return timestamp.strftime('%Y%m%d%H%M%S')
1105234
def _log_changes(ret, changekey, changevalue):
    '''
    
    '''
    cl = ret['changes'].get('new', [])
    cl.append({changekey: _object_reducer(changevalue)})
    ret['changes']['new'] = cl
    return ret
1312043
def get_diff(self, commit, other_commit):
        
        print(other_commit, "VS", commit)
        diff = self.repo.git.diff(commit, other_commit)
        return Diff(diff).get_totals()
584884
def _init_repo(self):
        
        log.debug("initializing new Git Repo: {0}".format(self._engine_path))
        if os.path.exists(self._engine_path):
            log.error("Path already exists! Aborting!")
            raise RuntimeError
        else:
            # create the repo if it doesn't already exist
            _logg_repo = git.Repo.init(path=self._engine_path, mkdir=True)
            record = "idid Logg repo initialized on {0}".format(today())
            c = _logg_repo.index.commit(record)
            assert c.type == 'commit'
            log.info('Created git repo [{0}]'.format(self._engine_path))
        return _logg_repo
492827
def do_commits(self):
        
        git_clone_command = "git clone " + str(self.git_repo_url)
        subprocess.call(git_clone_command, shell=True)
        subprocess.check_call(
            ['touch', 'gitHeart.txt'], cwd=self.repository_name)
        self.append_onto_file(self.repository_name+"/gitHeart.txt", HEADER)
        subprocess.check_call(
            ['git', 'add', 'gitHeart.txt'], cwd=self.repository_name)
        subprocess.check_call(
            ['git', 'commit', '-m', '"Commit Number 0"'], cwd=self.repository_name)
        for commit_number in range(1, len(MARKED_DAYS)*self.max_commits+1):
            heart_msg = HEART.format(commit_number=str(commit_number))
            self.append_onto_file(
                self.repository_name+"/gitHeart.txt", heart_msg)
            subprocess.check_call(
                ['git', 'add', 'gitHeart.txt'], cwd=self.repository_name)
            subprocess.check_call(['git', 'commit', '-m', '"Commit Number {commit_number}"'.format(
                commit_number=commit_number)], cwd=self.repository_name)
        subprocess.check_call(
            ['git', 'push', 'origin', 'master'], cwd=self.repository_name)
1042153
def sort(self):
        """"""
        self.sorted_commits = sorted(self.commits,
                                     key=lambda x: x.committer_time,
                                     reverse=True)
        return self.sorted_commits
456739
def snapshot_statistics(self):
        
        with self._lock:

            stats = {
                'request_count': self.request_count,
                'borrow_count': self.borrow_count,
                'sampled_count': self.sampled_count,
            }

            self._reset_statistics()
            return stats
794251
def created(self, instance, commit=True):
        
        if commit:
            self.session_manager.save(instance, commit=True)
        return instance, HTTPStatus.CREATED
959384
def commit_deltas_from(other_repo, ref = "master", other_ref = "master")
      # TODO: we should be able to figure out the branch point, rather than
      # rev-list'ing the whole thing
      repo_refs       = self.git.rev_list({}, ref).strip.split("\n")
      other_repo_refs = other_repo.git.rev_list({}, other_ref).strip.split("\n")

      (other_repo_refs - repo_refs).map do |refn|
        Commit.find_all(other_repo, refn, {:max_count => 1}).first
      end
    end
847400
def changelog():
    # type: () -> str
    
    # Skip 'v' prefix
    versions = [x for x in git.tags() if versioning.is_valid(x[1:])]

    cmd = 'git log --format=%H'
    if versions:
        cmd += ' {}..HEAD'.format(versions[-1])

    hashes = shell.run(cmd, capture=True).stdout.strip().splitlines()
    commits = [git.CommitDetails.get(h) for h in hashes]

    tags = conf.get('changelog.tags', [
        {'header': 'Features', 'tag': 'feature'},
        {'header': 'Changes', 'tag': 'change'},
        {'header': 'Fixes', 'tag': 'fix'},
    ])

    results = OrderedDict((
        (x['header'], []) for x in tags
    ))

    for commit in commits:
        commit_items = extract_changelog_items(commit.desc, tags)
        for header, items in commit_items.items():
            results[header] += items

    lines = [
        '<35>v{}<0>'.format(versioning.current()),
        '',
    ]
    for header, items in results.items():
        if items:
            lines += [
                '',
                '<32>{}<0>'.format(header),
                '<32>{}<0>'.format('-' * len(header)),
                '',
            ]
            for item_text in items:
                item_lines = textwrap.wrap(item_text, 77)
                lines += ['- {}'.format('\n  '.join(item_lines))]

            lines += ['']

    return '\n'.join(lines)
397572
def get_oldest_commit(self):
        '''
        
        '''
        return self.git.get_commits(self.content.source_path, self.follow)[-1]
571391
def commit(self):
        
        assert self.record
        result = self.files_written, self.dirs_created
        self._init_record()
        return result
498067
def repo_values(self):
        
        branches = []
        commits = {}
        m_helper = Tools()
        status = m_helper.repo_branches(self.parentApp.repo_value['repo'])
        # branches and commits must both be retrieved successfully
        if status[0]:
            branches = status[1]
            status = m_helper.repo_commits(self.parentApp.repo_value['repo'])
            if status[0]:
                r_commits = status[1]
                for commit in r_commits:
                    commits[commit[0]] = commit[1]
            else:
                # if commits failed, return commit errors
                return status
        else:
            # if branch failed, return branch errors
            return status
        # if everything is good, return branches with commits
        return branches, commits
1209191
def log(commit = 'master', path = nil, options = {})
      default_options = {:pretty => "raw"}
      actual_options  = default_options.merge(options)
      arg = path ? [commit, '--', path] : [commit]
      commits = self.git.log(actual_options, *arg)
      Commit.list_from_string(self, commits)
    end