Python git 模块,Actor() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用git.Actor()

项目:mimiron    作者:ImageIntelligence    | 项目源码 | 文件源码
def generate_commit_message(repo, env='default', author=None):
    """Generates a generic commit message.

    Args:
        repo (git.objects.Repo): The git repository to commit against
        env (str): The infrastructure you're bumping against
        author (Optional[git.objects.Actor]): Commit author, host user by default

    Returns:
        str: The generated generic commit message

    """
    author = author if author else helpers.get_host_author(repo)
    return '\n'.join([
        'chore(git): trigger deploy with empty commit',
        '\n'
        'committed-by: %s <%s>' % (author.name, author.email,),
        'environment: %s' % (env,),
        '\n'
        'Committed via Mimiron v%s (https://github.com/ImageIntelligence/mimiron)' % (__version__,)
    ])
项目:mimiron    作者:ImageIntelligence    | 项目源码 | 文件源码
def commit_changes(repo, commit_message):
    """Commits all changes (staged and untracked) in a single commit.

    Args:
        repo (git.objects.Repo): The git repository to commit changes to
        commit_message (str): The commit message to use

    Returns:
        bool: True if a commit was made, False otherwise

    """
    if not repo.is_dirty():
        return False

    repo.git.add(u=True)
    actor = Actor(const.COMMIT_AUTHOR_NAME, email=const.COMMIT_AUTHOR_EMAIL)
    commit = repo.index.commit(commit_message, author=actor, committer=actor)

    io.info('commit message: "%s"' % (commit_message.split('\n')[0]),)
    io.info('created commit: (id) %s' % (commit.name_rev,))
    return True
项目:Orange-Juice-Problem-Control    作者:function-x    | 项目源码 | 文件源码
def __init__(self, root, testMode=False):
        super(GitManager, self).__init__()
        self.root = root
        self.commitTable = {}  # ??????????(submodule, last push binsha)???
        self.ownerRepo = None
        try:
            self.problemHub = git.Repo(root)
            self.readLastCommitBinsha()
        except git.InvalidGitRepositoryError:
            if not testMode:
                self.problemHub = self.setup()
            else:
                pass
        except FileNotFoundError:
            self.commitTable = {}
        # self.acrot = git.Actor(author, authorEmaill)

    # def __str__(self):
项目:genlog    作者:inconvergent    | 项目源码 | 文件源码
def __commit_all(self, thumb, m):
    from os import sep
    from git import Actor

    info_file = thumb.split(sep)[-1]
    self.repo.git.add('-A')
    self.repo.git.add(thumb, '-f')

    email = self.__get_author()
    a = None
    if email:
      a = Actor('genlog', email)

    if m:
      s = m
    else:
      s = ':genlog:'

    s += '\n\n:thumb:{:s}'.format(info_file)
    self.repo.index.commit(s, committer=a, author=a)
项目:BookCloud    作者:livro-aberto    | 项目源码 | 文件源码
def commit(project, branch):
    if (current_user != branch.owner and
        current_user != project.get_master().owner):
        flash(_('You are not the owner of this or the master branch'), 'error')
        return redirect(url_for('branches.view', project=project.name,
                                branch=branch.name, filename='index.html'))
    # will be deprecated
    merging = get_merging(project.name, branch.name)
    if merging:
        flash(_('You need to finish merging'), 'error')
        return redirect(url_for('branches.merge', project=project.name,
                                branch=branch.name, other=merging['branch']))
    ####################
    user_repo_path = join('repos', project.name, branch.name)
    repo = git.Repo(join(user_repo_path, 'source'))
    form = CommitForm(request.form)
    if request.method == 'POST' and form.validate():
        author = git.Actor(current_user.username, current_user.email)
        if len(form.message.data):
            message = form.message.data
        else:
            message = _('Some changes')
        repo.index.commit(message, author=author)
        origin = branch.origin
        if branch != origin:
            git_api = repo.git
            git_api.push('origin', branch.name)
            flash(_('Page submitted to _%s') % origin.name, 'info')
        update_subtree(project, branch)
        flash(_('Change commited'), 'info')
        return redirect(url_for('branches.view', project=project.name,
                                branch=branch.name, filename='index'))
    diff = repo.git.diff('--cached')
    return render_template('commit.html', form=form, diff=diff)
项目:BookCloud    作者:livro-aberto    | 项目源码 | 文件源码
def __init__(self, name, user):
        self.name = name
        self.owner_id = user.id
        # create the master branch
        new_branch = application.branches.Branch('master', self, None, user)
        db.session.add(new_branch)
        db.session.commit()
        # updating branch's self reference
        new_branch.origin_id = new_branch.id
        db.session.commit()
        # create folder for resources
        os.makedirs(join('repos', name, '_resources'))
        os.makedirs(join('repos', name, '_resources/original'))
        os.makedirs(join('repos', name, '_resources/low_resolution'))
        os.makedirs(join('repos', name, '_resources/thumbnail'))
        # create the repository in the filesystem
        repo_path = join('repos', name, 'master/source')
        os.makedirs(repo_path)
        os.symlink(os.path.abspath(join('repos', name, '_resources',
                                        'low_resolution')),
                   os.path.abspath(join('repos', name,
                                        'master/source/_resources/')))
        git.Repo.init(repo_path)
        repo = git.Repo(repo_path)
        application.branches.config_repo(repo, user.username, user.email)
        copyfile('empty_repo/source/index.rst', join(repo_path, 'index.rst'))
        copyfile('empty_repo/.gitignore', join(repo_path, '.gitignore'))
        repo.index.add(['index.rst', '.gitignore'])
        author = git.Actor(user.username, user.email)
        repo.index.commit(_('Initial commit'), author=author)
        new_branch.build(timeout=30)
项目:tidyextractors    作者:networks-lab    | 项目源码 | 文件源码
def handle_actor(name, obj):
    """
    Actor object handler.
    :param name: Unused String
    :param obj: GitPython Actor
    :return: Dictionary of attributes.
    """
    return {'author_name': obj.name,
            'author_email': obj.email}


# Handler functions to turn objects into usable attributes.
#   Functions return a dictionary of attributes, which
#   will appear in a row of the pandas dataframe.
项目:mimiron    作者:ImageIntelligence    | 项目源码 | 文件源码
def generate_service_bump_commit_message(repo, service_name, env, tag, author=None):
    """Generates an appropriate service bump commit message.

    Args:
        repo (git.objects.Repo): The git repository to commit against
        service_name (str): The service/app you're bumping
        env (str): The infrastructure you're bumping against
        tag (str): The service/app artifact tag (e.g. Docker tag)
        author (Optional[git.objects.Actor]): Commit author, host user by default

    Returns:
        str: The formatted bump commit message

    """
    env_name = env or 'default'  # Show 'default' if a repo does not have a default environment
    author = author if author else helpers.get_host_author(repo)
    return '\n'.join([
        'chore(tfvars): bump %s#%s "%s"' % (service_name, tag[:7], env_name,),
        '\n'
        'committed-by: %s <%s>' % (author.name, author.email,),
        'service-name: %s' % (service_name,),
        'service-tag: %s' % (tag,),
        'environment: %s' % (env_name,),
        '\n'
        'Committed via Mimiron v%s (https://github.com/ImageIntelligence/mimiron)' % (__version__,),
    ])
项目:builds    作者:open-power-host-os    | 项目源码 | 文件源码
def commit_changes(self, commit_message, committer_name, committer_email):
        """
        Commit all changes made to the repository.

        Args:
            commit_message (str): message describing the commit
            committer_name (str): committer name
            committer_email (str): committer email
        """
        LOG.info("Adding files to repository index")
        self.index.add(["*"])

        LOG.info("Committing changes to local repository")
        actor = git.Actor(committer_name, committer_email)
        self.index.commit(commit_message, author=actor, committer=actor)
项目:spdx-github    作者:spdx    | 项目源码 | 文件源码
def commit_file(file_name, repo, environment):
    #The index of the repo is used to add the spdx file to be committed.
    index = repo.index
    #Add the SPDX file to be committed
    index.add([file_name])
    repo.git.add(file_name)
    #Set the author, committer, and commit message.
    author = Actor(environment['git_name'], environment['git_email'])
    committer = Actor(environment['git_name'], environment['git_email'])
    commit_message = environment['git_commit_message']
    #Get the head commit
    head_commit = str(repo.head.commit)
    #Make the commit locally of the new SPDX file
    index.commit(commit_message, author=author, committer=committer)
项目:openkamer    作者:openkamer    | 项目源码 | 文件源码
def do(self):
        logger.info('BEGIN')
        try:
            repo = Repo(settings.DATA_REPO_DIR)
            assert not repo.bare
            # origin = repo.create_remote('origin', repo.remotes.origin.url)
            # origin.pull()

            parties = scraper.political_parties.search_parties()
            filepath = os.path.join(settings.DATA_REPO_DIR, 'fracties/fracties.csv')
            scraper.political_parties.create_parties_csv(parties, filepath)

            changed_files = repo.git.diff(name_only=True)
            if not changed_files:
                logger.info('no changes')
                logger.info('END')
                return

            filepath_date = os.path.join(settings.DATA_REPO_DIR, 'fracties/date.txt')
            with open(filepath_date, 'w') as fileout:
                fileout.write(datetime.date.today().strftime('%Y-%m-%d'))

            index = repo.index
            index.add(['fracties/fracties.csv', 'fracties/date.txt'])
            author = Actor(settings.GIT_AUTHOR_NAME, settings.GIT_AUTHOR_EMAIL)
            index.commit(
                message='update of tweedekamer.nl fracties',
                author=author
            )
            # origin.push()
        except:
            logger.error(traceback.format_exc())
            raise
        logger.info('END')
项目:openkamer    作者:openkamer    | 项目源码 | 文件源码
def do(self):
        logger.info('BEGIN')
        try:
            repo = Repo(settings.DATA_REPO_DIR)
            assert not repo.bare
            # origin = repo.create_remote('origin', repo.remotes.origin.url)
            # origin.pull()

            parties = scraper.parliament_members.search_members()
            filepath = os.path.join(settings.DATA_REPO_DIR, 'kamerleden/tweedekamerleden.csv')
            scraper.parliament_members.create_members_csv(parties, filepath)

            changed_files = repo.git.diff(name_only=True)
            if not changed_files:
                logger.info('no changes')
                logger.info('END')
                return

            filepath_date = os.path.join(settings.DATA_REPO_DIR, 'kamerleden/date.txt')
            with open(filepath_date, 'w') as fileout:
                fileout.write(datetime.date.today().strftime('%Y-%m-%d'))

            index = repo.index
            index.add(['kamerleden/tweedekamerleden.csv', 'kamerleden/date.txt'])
            author = Actor(settings.GIT_AUTHOR_NAME, settings.GIT_AUTHOR_EMAIL)
            index.commit(
                message='update of tweedekamer.nl kamerleden',
                author=author
            )
            # origin.push()
        except:
            logger.error(traceback.format_exc())
            raise
        logger.info('END')