当前位置: 首页>>代码示例>>Python>>正文


Python Repo.iter_commits方法代码示例

本文整理汇总了Python中git.Repo.iter_commits方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.iter_commits方法的具体用法?Python Repo.iter_commits怎么用?Python Repo.iter_commits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git.Repo的用法示例。


在下文中一共展示了Repo.iter_commits方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_insert_remove

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
    def test_insert_remove(self):
        self.gen_fake_2()
        self.window.refresh(force=True)

        master_view = self.window.rebase_main_class.get_branch_view("master")

        master_model = [model for model in self.window._models.values()
                        if model.name_to_display() == "master"][0]
        wallace_model = [model for model in self.window._models.values()
                         if model.name_to_display() == "wallace_branch"][0]

        master_model.start_history_event()

        master_view.remove_rows([3,])
        data_to_drop = wallace_model.mimeData(
                                        [wallace_model.createIndex(1, 0),])
        master_model.dropMimeData(data_to_drop, Qt.CopyAction, 1, 0, None)

        a_repo = Repo(self.TEST_dir)
        commits = list(a_repo.iter_commits())
        master_branch = a_repo.branches["master"]
        commits = list(a_repo.iter_commits(rev=master_branch))
        orig_message = commits[1].message

        wallace_branch = a_repo.branches["wallace_branch"]
        commits = list(a_repo.iter_commits(rev=wallace_branch))
        inserted_message = commits[1].message

        self.window.apply_models((master_model,), True, True)

        commits = list(a_repo.iter_commits(rev=master_branch))
        new_message = commits[1].message

        self.check(new_message, inserted_message, "Insertion failed")
开发者ID:mike-perdide,项目名称:gitbuster,代码行数:36,代码来源:tests_rebase_tab.py

示例2: update_status_from_proj

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
def update_status_from_proj(state, proj):
    fname = os.path.join(proj.get_local_repo_dir(), 'scripts',
                         state.state.lower(), 'STATUS')
    if os.path.exists(fname):
        state_name = state.state.lower()
        config = ConfigParser.ConfigParser()
        config.read(fname)
        section = config.sections()[0]
        for key, func in attributes.iteritems():
            if config.has_option(section, key):
                val = getattr(config, func)(section, key)
                setattr(state, key, val)

        # commits
        repo = Repo(proj.get_local_repo_dir())
        commits = list(repo.iter_commits(paths='scripts/' + state_name))
        if commits:
            state.num_commits = len(commits)
            state.latest_commit = datetime.datetime.fromtimestamp(
                commits[0].committed_date)

            for c in commits:
                author = Contributor.objects.lookup(c.author.name,
                                                    c.author.email)
                state.contributors.add(author)

    return state
开发者ID:Empact,项目名称:fiftystates,代码行数:29,代码来源:update_status.py

示例3: get_number_contributors

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
    def get_number_contributors(self):
        """Method for getting number of authors for each repository.
        :return:
            Dictionary: {<repository_name>: <number_of_different_authors>}"""

        temp_path = os.path.dirname(os.path.realpath("IPythonProject"))
        path_project = temp_path + "\\NewGitHubProjects\\"
        number_authors = {}
        # a list for containing all the different contributors and if we need it
        # all_different_authors= []

        for dir in os.listdir(path_project):
            different_authors = []
            for d in os.listdir(path_project + "\\" + dir):
                repo = Repo(path_project + "\\" + dir + "\\" + d, search_parent_directories=True)
                if repo.active_branch.is_valid():
                    commits = list(repo.iter_commits())
                    for commit in commits:
                        commit_author = commit.author
                        if commit_author not in different_authors:
                            different_authors.append(commit_author)

            # a list for containing all the different contributors and if we need it
            # all_different_contributors.append(different_contributors)
            number_authors.update({dir: len(different_authors)})

        return number_authors
开发者ID:CCSoti,项目名称:IPython_Observatory,代码行数:29,代码来源:commits_authors.py

示例4: get_commit_log

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
def get_commit_log():
    """
    Yields all commit messages from last to first.
    """
    repo = Repo('.git')
    for commit in repo.iter_commits():
        yield commit.message
开发者ID:jvrsantacruz,项目名称:python-semantic-release,代码行数:9,代码来源:vcs_helpers.py

示例5: run

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
    def run(self):
        env = self.state.document.settings.env
        config = env.config
        repodir = env.srcdir + '/' + config["git_repository_root"]

        doc_path = env.srcdir + '/' + env.docname + config["source_suffix"]

        if self.options.get('dir', False) == None:
            doc_path = '/'.join(doc_path.split('/')[:-1])

        repo = Repo(repodir)
        commits = repo.iter_commits(paths=doc_path)
        l = nodes.bullet_list()
        revisions_to_display = self.options.get('revisions', 10)

        for commit in list(commits)[:revisions_to_display]:
            date_str = datetime.fromtimestamp(commit.authored_date)
            if '\n' in commit.message:
                message, detailed_message = commit.message.split('\n', 1)
            else:
                message = commit.message
                detailed_message = None

            item = nodes.list_item()
            item += [
                nodes.strong(text=message),
                nodes.inline(text=" by "),
                nodes.emphasis(text=str(commit.author)),
                nodes.inline(text=" at "),
                nodes.emphasis(text=str(date_str))
            ]
            if detailed_message:
                item.append(nodes.caption(text=detailed_message.strip()))
            l.append(item)
        return [l]
开发者ID:xiu,项目名称:sphinx-git,代码行数:37,代码来源:sphinx_git.py

示例6: update_repo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
    def update_repo(self, project):
        from ostracker.models import Commit, Contributor
        proj_dir = project.get_local_repo_dir()

        # checkout or update project
        if not os.path.exists(proj_dir):
            print 'cloning %s' % project
            os.system('git clone -q %s %s' % (project.get_remote_repo_url(),
                                              proj_dir))
        else:
            print 'updating %s' % project
            os.system('cd %s && git pull -q' % proj_dir)

        # process new commits
        repo = Repo(proj_dir)
        added = 0
        for c in repo.iter_commits():
            try:
                Commit.objects.get(id=c.sha)
            except Commit.DoesNotExist:
                added += 1
                stats = c.stats.total

                cdate = datetime.datetime.fromtimestamp(c.committed_date)

                author = Contributor.objects.lookup(c.author.name, c.author.email)

                Commit.objects.create(id=c.sha, project=project, author=author,
                                      message=c.message, time_committed=cdate,
                                      deletions=stats['deletions'],
                                      files=stats['files'],
                                      insertions=stats['insertions'],
                                      lines=stats['lines'])
        print 'added %s commits to %s' % (added, project)
开发者ID:pombredanne,项目名称:django-ostracker,代码行数:36,代码来源:github.py

示例7: test_scrape_single

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
 def test_scrape_single(self):
     repo = Repo(local_url, odbt=GitCmdObjectDB)
     commit = list(repo.iter_commits())[0]
     activity = scraper._commit2activity(commit=commit)
     self.assertIsNotNone(activity)
     self.assertIsNotNone(activity.login)
     self.assertIsNotNone(activity.date)
开发者ID:sema,项目名称:django-2012,代码行数:9,代码来源:tests.py

示例8: load

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
    def load(prj):

        # prj.load_info()
        # repo = Repo(cfg['root_dir'])
        repo = Repo(prj.root_dir)

        it = list(repo.iter_commits(**list_options))
        if len(it) == 0:
            # print("20160816 no commits in {}".format(prj.nickname))
            return

        def fmtcommit(c):

            url = repo.remotes.origin.url
            if url.startswith("[email protected]"):
                url = "https://github.com/" + url[15:-4] \
                      + "/commit/" + c.hexsha
            elif url.startswith("git+ssh://[email protected]b.com"):
                url = "https://github.com/" + url[25:-4] \
                      + "/commit/" + c.hexsha

            s = "`{0} <{1}>`__".format(c.hexsha[-7:], url)
            # if c.message and not c.message.startswith("http://"):
            s += "\n({})".format(c.message.strip())
            return s

        # url = prj.SETUP_INFO.get('url', "oops")
        # desc = "`%s <%s>`__" % (prj.name, url)
        desc = "*{}*".format(prj.nickname)

        for c in it:
            # ts = time.strftime("%H:%M", time.gmtime(c.committed_date))
            ts = time.strftime("%Y-%m-%d %H:%M", time.localtime(c.committed_date))
            rows.append([ts, desc, fmtcommit(c)])
开发者ID:lino-framework,项目名称:atelier,代码行数:36,代码来源:tasks.py

示例9: get_commits

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
def get_commits(repo_name, db):
    url = get_repo_url(repo_name)
    repo = Repo(url)
    commits = list(repo.iter_commits('master'))
    commits_len = len(commits)
    for i in range(0, commits_len-1):
        commit_cur = commits[i]
        commit_prev = commits[i+1]
        minus = 1
        plus = 1
        try:
            diff_str = repo.git.diff(commit_cur, commit_prev)
        except Exception:
            print "exception in encode utf8"
            
        else:
            (minus, plus) = get_diff_meta(diff_str)
        commit_data = {"uniq": repo_name + '/' + str(commit_cur),
                       "repo_name": repo_name,
                       "sha": str(commit_cur),
                       "author": commit_cur.author.name,
                       "email": commit_cur.author.email,
                       "authored_date": commit_cur.authored_date,
                       "committed_date": commit_cur.committed_date,
                       "message": commit_cur.message, 
                       "encoding": commit_cur.encoding,
                       "minus": minus, "plus": plus}
        if db["git2db"].find_one({"uniq": repo_name + '/' + str(commit_cur)}):
            continue
        else:
            db["git2db"].insert(commit_data)
开发者ID:initlove,项目名称:git2db,代码行数:33,代码来源:Git2DB.py

示例10: UserRepo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
class UserRepo(object):
    def __init__(self, path, emails=None):
        self.repo = Repo(path)
        if not emails:
            email = get_user_email()
            if email:
                emails = [email]
            else:
                emails = []
        self.emails = emails

    @property
    def branches(self):
        return [str(i) for i in self.repo.branches]

    def get_date_commits(self, since, until=None, branches=None):
        commit_set = CommitSet(self)
        if not branches:
            branches = self.branches

        logging.debug('branches: %s', branches)

        for branch in branches:
            print '---'
            # If we need date comparision then authored_date is the choice
            # as it is smaller or equal to committed_date
            for i in self.repo.iter_commits(branch, since=since, until=until):
                logging.debug('commit message: %s', i.message)
                if i.author.email in self.emails:
                    commit_set.add(i, branch)

        commit_set.sort('time')
        return commit_set
开发者ID:reorx,项目名称:workjournal,代码行数:35,代码来源:gitutil.py

示例11: run

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
    def run(self):
        env = self.state.document.settings.env
        repo = Repo(env.srcdir)
        commits = repo.iter_commits()
        l = nodes.bullet_list()
        for commit in list(commits)[:10]:
            date_str = datetime.fromtimestamp(commit.authored_date)
            if '\n' in commit.message:
                message, detailed_message = commit.message.split('\n', 1)
            else:
                message = commit.message
                detailed_message = None

            item = nodes.list_item()
            item += [
                nodes.strong(text=message),
                nodes.inline(text=" by "),
                nodes.emphasis(text=str(commit.author)),
                nodes.inline(text=" at "),
                nodes.emphasis(text=str(date_str))
            ]
            if detailed_message:
                item.append(nodes.caption(text=detailed_message.strip()))
            l.append(item)
        return [l]
开发者ID:AirSage,项目名称:sphinx-git,代码行数:27,代码来源:sphinx_git.py

示例12: show_commit_index

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
def show_commit_index(repopath='', branchname='master', page=1):
    '''
    Provides the index data for commits.

    :arg repopath: Path to the git repo
    :arg branchname: Branch we want to show, default is `master`.
    :arg page: Integer pagenumber
    '''
    repo = Repo(repopath)
    skip = (page - 1 ) * 5
    itercommits = repo.iter_commits(branchname, max_count=5, skip=skip)
    result = []
    for com in itercommits:
        data = {}
        data['author'] = com.author
        if len(com.summary) > 50:
            text = com.summary[:50]
            text += '...'
        else:
            text = com.summary
        data['text'] = text
        data['message'] = com.message
        data['hex'] = com.hexsha
        data['total'] = com.stats.total
        data['time'] = time.asctime(time.gmtime(com.committed_date))
        result.append(data)

    return result
开发者ID:Sanjiban,项目名称:kickit,代码行数:30,代码来源:utils.py

示例13: count_authors

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
def count_authors(project_name):
    #TARGET_PATH = "./target/"
    repo = Repo(project_name)
    file_dic = defaultdict(lambda: defaultdict(int))
    for commit in repo.iter_commits('master'):
        for file in commit.stats.files.keys():
            file_dic[file][commit.author.name] += 1
    return file_dic
开发者ID:TomohiroIchinose,项目名称:Project-analyzer-for-ROCAT,代码行数:10,代码来源:author.py

示例14: Repository

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
class Repository(object):
    def __init__(self, directory):
        self.root = directory
        self.repo = Repo(self.root)
        self.tree = self.repo.heads.master.commit.tree
        self.description = self.repo.description

    def __eq__(self, other):
        return hash(self) == hash(other)

    def __hash__(self):
        return int(md5(str(self)).hexdigest(), 16)

    def __repr__(self):
        return str(self)

    def __str__(self):
        return self.root.encode('utf-8')

    @memoize
    def _get_creation_datetime(self):
        timestamp = self.commits[-1].authored_date
        return datetime.fromtimestamp(timestamp)

    creation_datetime = property(_get_creation_datetime)

    @memoize_for_head
    def _get_commits(self):
        return list(self.repo.iter_commits())

    commits = property(_get_commits)

    @memoize_for_head
    def _get_posts(self):
        """
        Returns a list of posts, unsorted.
        """
        posts = [Post(self.root, b.path.encode('utf-8')) for b in \
                     self.tree.blobs]
        return posts

    posts = property(_get_posts)

    @memoize_for_head
    def _get_update_datetime(self):
        timestamp = self.commits[0].authored_date
        return datetime.fromtimestamp(timestamp)

    update_datetime = property(_get_update_datetime)

    @memoize_for_head
    def _get_archive(self):
        """Returns all posts in a POSIX tar archive."""
        f = StringIO()
        self.repo.archive(f)
        return f.getvalue()

    archive = property(_get_archive)
开发者ID:erlehmann,项目名称:buddleblag,代码行数:60,代码来源:model.py

示例15: count_commits

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import iter_commits [as 别名]
    def count_commits(site, working_directory):
        """ Return number of commits in a repo. """

        file_name = open(os.path.join(expanduser('~'), '.drupdates', 'settings.yaml'), 'r')
        settings = yaml.load(file_name)
        working_dir = os.path.join(expanduser('~'), '.drupdates', working_directory)
        folder = os.path.join(working_dir, settings['repoDict']['value'][site])
        repo = Repo(folder)
        return len(list(repo.iter_commits('dev')))
开发者ID:jalama,项目名称:drupdates,代码行数:11,代码来源:behavioral_utils.py


注:本文中的git.Repo.iter_commits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。