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


Python cmd.Git类代码示例

本文整理汇总了Python中git.cmd.Git的典型用法代码示例。如果您正苦于以下问题:Python Git类的具体用法?Python Git怎么用?Python Git使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fork

    def fork(self, new_body):
        git_path = mkdtemp(prefix=settings.GIT_ROOT_PATH)
        git = Git(git_path)
        git.clone(os.path.abspath(self.git_path), git_path)

        new_fork = Fork.objects.create(body=new_body, parent=self, git_path=git_path)
        return new_fork
开发者ID:ironfroggy,项目名称:fork-ws,代码行数:7,代码来源:models.py

示例2: init

	def init(cls, path=None, mkdir=True, **kwargs):
		"""Initialize a git repository at the given path if specified

		:param path:
			is the full path to the repo (traditionally ends with /<name>.git)
			or None in which case the repository will be created in the current 
			working directory

		:parm mkdir:
			if specified will create the repository directory if it doesn't
			already exists. Creates the directory with a mode=0755. 
			Only effective if a path is explicitly given

		:parm kwargs:
			keyword arguments serving as additional options to the git-init command

		:return: ``git.Repo`` (the newly created repo)"""

		if mkdir and path and not os.path.exists(path):
			os.makedirs(path, 0755)

		# git command automatically chdir into the directory
		git = Git(path)
		output = git.init(**kwargs)
		return Repo(path)
开发者ID:2flcastro,项目名称:ka-lite,代码行数:25,代码来源:base.py

示例3: init

    def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs):
        """Initialize a git repository at the given path if specified

        :param path:
            is the full path to the repo (traditionally ends with /<name>.git)
            or None in which case the repository will be created in the current
            working directory

        :parm mkdir:
            if specified will create the repository directory if it doesn't
            already exists. Creates the directory with a mode=0755.
            Only effective if a path is explicitly given

        :param odbt:
            Object DataBase type - a type which is constructed by providing
            the directory containing the database objects, i.e. .git/objects.
            It will be used to access all object data

        :parm kwargs:
            keyword arguments serving as additional options to the git-init command

        :return: ``git.Repo`` (the newly created repo)"""
        if path:
            path = _expand_path(path)
        if mkdir and path and not os.path.exists(path):
            os.makedirs(path, 0o755)

        # git command automatically chdir into the directory
        git = Git(path)
        git.init(**kwargs)
        return cls(path, odbt=odbt)
开发者ID:john5a18,项目名称:GitPython,代码行数:31,代码来源:base.py

示例4: commit

def commit(options, debug, info):
    path = getcwd()
    git = Git(path)

    debug(git.commit('-m', message(options['m'], 'commit')))

    info('Committed with message "{message}".'.format(message=options['m']))
开发者ID:Ponginae,项目名称:release-tool,代码行数:7,代码来源:pavement.py

示例5: get_days_since_last_update

def get_days_since_last_update(path):
    """
    :return: The days since the last update of any of the files in path. If the
             path points to a filename, the last update of that filename is
             returned.
    """
    git = Git(".")
    cmd_str = "git log -1 --format=%%cd %s" % path
    cmd = shlex.split(cmd_str)

    try:
        date_str = git.execute(command=cmd, with_extended_output=False)
    except GitCommandError:
        raise ValueError('"%s" is not in tracked by this repository.' % path)

    # The date_str is in the following format: Sat Jun 21 10:20:31 2014 -0300
    # We need to parse it, and then do some date math to return the result
    #
    # We ignore the UTC offset because it was "hard to parse" and we don't care
    last_commit_time = datetime.strptime(date_str[:-6], "%a %b %d %H:%M:%S %Y")
    last_commit_date = last_commit_time.date()

    today_date = date.today()

    time_delta = today_date - last_commit_date

    return time_delta.days
开发者ID:ZionOps,项目名称:w3af,代码行数:27,代码来源:file_utils.py

示例6: removeItem

    def removeItem(self, release, path, comment=None):
        result = None
        session = None
        try:
            session = self._manager.getSession()
            item = self._get_item(release, path)
            item = session.merge(item)
            target_path, target_name = self.__get_target(release, path)
            module = self._supportedItems[item.item_type]['module'](target_path, target_name)
            module.delete()

            # Commit changes
            if not comment:
                comment = "Change made with no comment"

            self.log.info("commiting changes for module %s" % target_name)
            cmd = Git(target_path)
            try:
                cmd.commit("-a", "-m", comment)
                cmd.push("origin")
            except GitCommandError as e:
                self.log.debug("no commit for %s: %s" % (target_name, str(e)))
            session.commit()
            result = True
        except:
            session.rollback()
            raise
        finally:
            session.close()
        result &= super(PuppetInstallMethod, self).removeItem(release, path)
        return result
开发者ID:lhm-limux,项目名称:gosa,代码行数:31,代码来源:methods.py

示例7: gitPush

    def gitPush(self, path, comment=None):
            # Announce changes to git
            cmd = Git(path)
            changed = False
            for line in cmd.status("--porcelain").splitlines():
                changed = True
                line = line.lstrip()
                self.log.info("staging changes for %s" % line.split(" ", 1)[1:])

                mode, file_path = line.split(" ", 1)
                file_path = os.path.join(*file_path.split("/")[0:])

                # Remove data?
                if mode == "D":
                    cmd.rm("-r", file_path)

                # Add data...
                else:
                    cmd.add(file_path)

            # No need to deal...
            if not changed:
                return False

            # Commit changes
            if not comment:
                comment = "Change made with no comment"

            self.log.info("committing changes for module %s" % path)
            cmd.commit("-m", comment)
            cmd.push("origin")

            return True
开发者ID:lhm-limux,项目名称:gosa,代码行数:33,代码来源:methods.py

示例8: init_remotes

def init_remotes():
    path = getcwd()
    git = Git(path)

    has_upstream = raw_input('Is this a fork? (y/N) ')
    if has_upstream.lower() == 'y':
        upstream = raw_input('What is the url of the upstream project? ')
        git.remote('add', 'upstream', upstream)
开发者ID:Ponginae,项目名称:release-tool,代码行数:8,代码来源:pavement.py

示例9: merge

 def merge(self, remoteref, wd=None, **kwargs):
     if wd is None:
         git = self.git
     else:
         git = Git(wd)
         git.extra = dict(self.git.extra)
         git.extra["env"]["GIT_WORK_TREE"] = wd
     git.merge(remoteref)
开发者ID:kergoth,项目名称:git-origin,代码行数:8,代码来源:cmd.py

示例10: command

    def command(self, command):
        """
        Runs the Git command in self.repo
        """
        args = split(command)

        cmd = Git(self.repodir)

        cmd.execute(args)
开发者ID:CedarWei,项目名称:git-sweep,代码行数:9,代码来源:testcases.py

示例11: merge_index

 def merge_index(self, *args, **kwargs):
     wd = kwargs.get("work_tree")
     if wd is None:
         git = self.git
     else:
         git = Git(wd)
         git.extra = dict(self.git.extra)
         git.extra["env"]["GIT_WORK_TREE"] = wd
     return git.merge_index(*args, **kwargs)
开发者ID:kergoth,项目名称:git-origin,代码行数:9,代码来源:cmd.py

示例12: init_branches

def init_branches(options, error, info, debug):
    path = getcwd()
    git = Git(path)
    create = options.release_tool_settings['branches']

    for branch in create:
        debug('creating branch "%s"...' % branch)
        debug(git.branch(branch))

    info('Created branches ' + ', '.join(create))
开发者ID:Ponginae,项目名称:release-tool,代码行数:10,代码来源:pavement.py

示例13: clone_from

    def clone_from(cls, url, to_path, progress=None, env=None, **kwargs):
        """Create a clone from the given URL

        :param url: valid git url, see http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS
        :param to_path: Path to which the repository should be cloned to
        :param progress: See 'git.remote.Remote.push'.
        :param env: Optional dictionary containing the desired environment variables.
        :param kwargs: see the ``clone`` method
        :return: Repo instance pointing to the cloned directory"""
        git = Git(os.getcwd())
        if env is not None:
            git.update_environment(**env)
        return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs)
开发者ID:john5a18,项目名称:GitPython,代码行数:13,代码来源:base.py

示例14: _clone

    def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
        if progress is not None:
            progress = to_progress_instance(progress)

        odbt = kwargs.pop('odbt', odb_default_type)

        # when pathlib.Path or other classbased path is passed
        if not isinstance(path, str):
            path = str(path)

        ## A bug win cygwin's Git, when `--bare` or `--separate-git-dir`
        #  it prepends the cwd or(?) the `url` into the `path, so::
        #        git clone --bare  /cygwin/d/foo.git  C:\\Work
        #  becomes::
        #        git clone --bare  /cygwin/d/foo.git  /cygwin/d/C:\\Work
        #
        clone_path = (Git.polish_url(path)
                      if Git.is_cygwin() and 'bare' in kwargs
                      else path)
        sep_dir = kwargs.get('separate_git_dir')
        if sep_dir:
            kwargs['separate_git_dir'] = Git.polish_url(sep_dir)
        proc = git.clone(Git.polish_url(url), clone_path, with_extended_output=True, as_process=True,
                         v=True, universal_newlines=True, **add_progress(kwargs, git, progress))
        if progress:
            handle_process_output(proc, None, progress.new_message_handler(), finalize_process, decode_streams=False)
        else:
            (stdout, stderr) = proc.communicate()
            log.debug("Cmd(%s)'s unused stdout: %s", getattr(proc, 'args', ''), stdout)
            finalize_process(proc, stderr=stderr)

        # our git command could have a different working dir than our actual
        # environment, hence we prepend its working dir if required
        if not osp.isabs(path) and git.working_dir:
            path = osp.join(git._working_dir, path)

        repo = cls(path, odbt=odbt)

        # retain env values that were passed to _clone()
        repo.git.update_environment(**git.environment())

        # adjust remotes - there may be operating systems which use backslashes,
        # These might be given as initial paths, but when handling the config file
        # that contains the remote from which we were clones, git stops liking it
        # as it will escape the backslashes. Hence we undo the escaping just to be
        # sure
        if repo.remotes:
            with repo.remotes[0].config_writer as writer:
                writer.set_value('url', Git.polish_url(repo.remotes[0].url))
        # END handle remote repo
        return repo
开发者ID:h3llrais3r,项目名称:Auto-Subliminal,代码行数:51,代码来源:base.py

示例15: __init__

    def __init__(self, *args, **kwargs):
        if not kwargs.get('parent', None):
            # Initialize a new repo
            git_path = mkdtemp(prefix=settings.GIT_ROOT_PATH)
            git = Git(git_path)
            git.init()

            body_path = os.path.join(git_path, 'BODY')

            self.message = "created new"

            kwargs['git_path'] = git_path

        super(Fork, self).__init__(*args, **kwargs)
开发者ID:ironfroggy,项目名称:fork-ws,代码行数:14,代码来源:models.py


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