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


Python Git.execute方法代码示例

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


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

示例1: processCommitHook

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def processCommitHook(self, req):
        self.env.log.debug("processCommitHook")
        status = self.closestatus
        if not status:
            status = 'closed'
	
        data = req.args.get('payload')
	jsondata = simplejson.loads(data)
		
	repoName = jsondata['repository']['name']

        if self.autofetch:
	    if data:
	    	jsondata = simplejson.loads(data)
		self.env.log.debug(jsondata['repository']['name']);
	        repo = Git(self.gitreposdir+repoName+"/.git")

            try:
              self.env.log.debug("Fetching repo %s" % self.repo)
              repo.execute(['git', 'fetch'])
              try:
                self.env.log.debug("Resyncing local repo")
                self.env.get_repository(repoName).sync()
              except:
                self.env.log.error("git sync failed!")
            except:
              self.env.log.error("git fetch failed!")

        jsondata = simplejson.loads(data)

         
        if jsondata:
            if jsondata['ref'] == "refs/heads/master" or re.search('-stable$', jsondata['ref']):
                for i in jsondata['commits']:
                    self.hook.process(i, status)
开发者ID:toutantic,项目名称:github-trac,代码行数:37,代码来源:github.py

示例2: processCommitHook

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def processCommitHook(self, req):
        self.env.log.debug("processCommitHook")
        status = self.closestatus
        if not status:
            status = 'closed'

        if self.autofetch:
            repodir = RepositoryManager(self.env).repository_dir
            if not os.path.isabs(repodir):
                repodir = os.path.join(self.env.path, repodir)
            # TODO: This was the previous code, the repo options is probably unecessary now.
			# repodir = "%s/%s" % (self.repo, reponame)
            self.env.log.debug("Autofetching: %s" % repodir)
            repo = Git(repodir)

            try:
              self.env.log.debug("Fetching repo %s" % self.repo)
              repo.execute(['git', 'fetch'])
              try:
                self.env.log.debug("Resyncing local repo")
                self.env.get_repository('').sync()
              except:
                self.env.log.error("git sync failed!")
            except:
              self.env.log.error("git fetch failed!")

        data = req.args.get('payload')
         
        if data:
            jsondata = simplejson.loads(data)
            reponame = jsondata['repository']['name']

            for i in jsondata['commits']:
                self.hook.process(i, status, self.enable_revmap,reponame)
开发者ID:mickelangelo,项目名称:github-trac,代码行数:36,代码来源:github.py

示例3: processCommitHook

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def processCommitHook(self, req):
        self.env.log.debug("processCommitHook")
        status = self.closestatus
        if not status:
            status = 'closed'

        data = req.args.get('payload')
        branches = (parse_qs(req.query_string).get('branches') or self.branches).split(',')
        self.env.log.debug("Using branches: %s", branches)

        if data:
            jsondata = simplejson.loads(data)
            ref = jsondata['ref'].split('/')[-1]

            if ref in branches or 'all' in branches:
                for i in jsondata['commits']:
                    self.hook.process(i, status, jsondata)
            else:
                self.env.log.debug("Not running hook, ref %s is not in %s", ref, branches)

        if self.autofetch:
            repo = Git(self.repo)

            try:
              repo.execute(['git', 'fetch'])
            except:
              self.env.log.debug("git fetch failed!")
开发者ID:dnarvaez,项目名称:github-trac,代码行数:29,代码来源:github.py

示例4: command

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def command(self, command):
        """
        Runs the Git command in self.repo
        """
        args = split(command)

        cmd = Git(self.repodir)

        cmd.execute(args)
开发者ID:Mondego,项目名称:pyreco,代码行数:11,代码来源:allPythonContent.py

示例5: _GitWrapperCommon

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
class _GitWrapperCommon(object):
    '''
    Wrap git module to provide a more stable interface across versions
    '''
    def __init__(self, repo_path):
        self.git = Git()
        self.repo = Repo(os.path.abspath('.'))

    def is_file_managed_by_git(self, path):
        '''
        :param path: Path to check
        :returns: True if path is managed by git
        '''
        status, _stdout, _stderr = self.git.execute(
            ['git', 'ls-files', path, '--error-unmatch'],
            with_extended_output=True,
            with_exceptions=False)
        return status == 0

    def is_file_modified(self, path):
        '''
        Does a file have local changes not yet committed

        :returns: True if file has local changes
        '''
        status, _stdout, _stderr = self.git.execute(
            ['git', 'diff', '--quiet', 'HEAD', path],
            with_extended_output=True,
            with_exceptions=False)
        return status != 0

    def get_commits_following(self, path):
        '''
        Get all commits including path following the file through
        renames

        :param path: Path which we will find commits for
        :returns: Sequence of commit objects. Newest to oldest
        '''
        commit_shas = self.git.log(
            '--pretty=%H', '--follow', '--', path).splitlines()
        return map(self.repo.commit, commit_shas)

    def get_commits(self, path, follow=False):
        '''
        Get all commits including path

        :param path: Path which we will find commits for
        :param bool follow: If True we will follow path through renames

        :returns: Sequence of commit objects. Newest to oldest
        '''
        if follow:
            return self.get_commits_following(path)
        else:
            return self._get_commits(path)
开发者ID:HeavyThumper,项目名称:pelican-plugins,代码行数:58,代码来源:git_wrapper.py

示例6: _GitWrapperCommon

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
class _GitWrapperCommon(object):
    """
    Wrap git module to provide a more stable interface across versions
    """

    def __init__(self, repo_path):
        self.git = Git()
        self.repo = Repo(os.path.abspath("."))

    def is_file_managed_by_git(self, path):
        """
        :param path: Path to check
        :returns: True if path is managed by git
        """
        status, _stdout, _stderr = self.git.execute(
            ["git", "ls-files", path, "--error-unmatch"], with_extended_output=True, with_exceptions=False
        )
        return status == 0

    def is_file_modified(self, path):
        """
        Does a file have local changes not yet committed

        :returns: True if file has local changes
        """
        status, _stdout, _stderr = self.git.execute(
            ["git", "diff", "--quiet", "HEAD", path], with_extended_output=True, with_exceptions=False
        )
        return status != 0

    def get_commits_following(self, path):
        """
        Get all commits including path following the file through
        renames

        :param path: Path which we will find commits for
        :returns: Sequence of commit objects. Newest to oldest
        """
        commit_shas = self.git.log("--pretty=%H", "--follow", "--", path).splitlines()
        return [self.repo.commit(shas) for shas in commit_shas]

    def get_commits(self, path, follow=False):
        """
        Get all commits including path

        :param path: Path which we will find commits for
        :param bool follow: If True we will follow path through renames

        :returns: Sequence of commit objects. Newest to oldest
        """
        if follow:
            return self.get_commits_following(path)
        else:
            return self._get_commits(path)
开发者ID:Raniz85,项目名称:blog.raneland.se,代码行数:56,代码来源:git_wrapper.py

示例7: _get_changes

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
 def _get_changes(self, path, remotepath, gitclient=None):
     ''' Get and print changes from repository
     TODO. Remove Git client and get it with naive clear
     '''
     check = Git(path)
     if gitclient != None:
         check = gitclient
     check.execute(["git", "checkout", "master"])
     try:
         return self._merge(check)
     except:
         self._fetchUpstream(check, remotepath)
         return self._merge(check)
开发者ID:saromanov,项目名称:gitupcheck,代码行数:15,代码来源:gitupcheck.py

示例8: TestGit

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
class TestGit(object):
    def setup(self):
        base = os.path.join(os.path.dirname(__file__), "../..")
        self.git = Git(base)

    @patch(Git, 'execute')
    def test_call_process_calls_execute(self, git):
        git.return_value = ''
        self.git.version()
        assert_true(git.called)
        assert_equal(git.call_args, ((['git', 'version'],), {}))

    @raises(GitCommandError)
    def test_it_raises_errors(self):
        self.git.this_does_not_exist()


    def test_it_transforms_kwargs_into_git_command_arguments(self):
        assert_equal(["-s"], self.git.transform_kwargs(**{'s': True}))
        assert_equal(["-s5"], self.git.transform_kwargs(**{'s': 5}))

        assert_equal(["--max-count"], self.git.transform_kwargs(**{'max_count': True}))
        assert_equal(["--max-count=5"], self.git.transform_kwargs(**{'max_count': 5}))

        assert_equal(["-s", "-t"], self.git.transform_kwargs(**{'s': True, 't': True}))

    def test_it_executes_git_to_shell_and_returns_result(self):
        assert_match('^git version [\d\.]{2}.*$', self.git.execute(["git","version"]))

    def test_it_accepts_stdin(self):
        filename = fixture_path("cat_file_blob")
        fh = open(filename, 'r')
        assert_equal("70c379b63ffa0795fdbfbc128e5a2818397b7ef8",
                     self.git.hash_object(istream=fh, stdin=True))
        fh.close()

    def test_it_handles_large_input(self):
        if sys.platform == 'win32':
            output = self.git.execute(["type", "C:\WINDOWS\system32\cmd.exe"])
        else:
            output = self.git.execute(["cat", "/bin/bash"])
        assert_true(len(output) > 4096) # at least 4k

    @patch(Git, 'execute')
    def test_it_ignores_false_kwargs(self, git):
        # this_should_not_be_ignored=False implies it *should* be ignored
        output = self.git.version(pass_this_kwarg=False)
        assert_true("pass_this_kwarg" not in git.call_args[1])
开发者ID:directeur,项目名称:git-python,代码行数:50,代码来源:test_git.py

示例9: full_remote

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
 def full_remote(self):
     # alextodo. wrap the calls to git commit
     repo = Git(self.path)
     cmd = ['git', 'remote', '-v']
     remote = repo.execute(cmd).split('(fetch)')[0]
     remote = remote or ''
     return remote.strip()
开发者ID:Doula,项目名称:Bambino,代码行数:9,代码来源:appenv.py

示例10: merged_refs

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def merged_refs(self, skip=[]):
        """
        Returns a list of remote refs that have been merged into the master
        branch.

        The "master" branch may have a different name than master. The value of
        ``self.master_name`` is used to determine what this name is.
        """
        origin = self._origin

        master = self._master_ref(origin)
        refs = self._filtered_remotes(
            origin, skip=['HEAD', self.master_branch] + skip)
        merged = []

        for ref in refs:
            upstream = '{origin}/{master}'.format(
                origin=origin.name, master=master.remote_head)
            head = '{origin}/{branch}'.format(
                origin=origin.name, branch=ref.remote_head)
            cmd = Git(self.repo.working_dir)
            # Drop to the git binary to do this, it's just easier to work with
            # at this level.
            (retcode, stdout, stderr) = cmd.execute(
                ['git', 'cherry', upstream, head],
                with_extended_output=True, with_exceptions=False)
            if retcode == 0 and not stdout:
                # This means there are no commits in the branch that are not
                # also in the master branch. This is ready to be deleted.
                merged.append(ref)

        return merged
开发者ID:Mondego,项目名称:pyreco,代码行数:34,代码来源:allPythonContent.py

示例11: previous

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
def previous(rel_ver):
    """
    Given a release version, find the previous version based on the latest Git
    tag that is strictly a lower version than the given release version.
    """
    if DEBUG:
        print 'Calculating previous release version (option -p was specified).'
    version_loose = LooseVersion('0.0.0')
    rel_ver_loose = LooseVersion(rel_ver)
    gexc = Git('.')
    tags = gexc.execute(['git', 'tag',
                         '--list', '1.*',
                         '--sort', '-version:refname'])
    for tag in tags.splitlines():
        previous_tag_match = PREVIOUS_TAG_RE.match(tag)
        if previous_tag_match:
            version_new = {}
            version_new['major'] = int(previous_tag_match.group('vermaj'))
            version_new['minor'] = int(previous_tag_match.group('vermin'))
            version_new['patch'] = int(previous_tag_match.group('verpatch'))
            new_version_loose = LooseVersion(str(version_new['major']) + '.' +
                                             str(version_new['minor']) + '.' +
                                             str(version_new['patch']))
            if new_version_loose < rel_ver_loose:
                version_loose = new_version_loose
                if DEBUG:
                    print 'Found new best version "' + str(version_loose) \
                            + '" from tag "' + tag + '"'
                return str(version_loose)

    return str(version_loose)
开发者ID:acmorrow,项目名称:mongo-c-driver,代码行数:33,代码来源:calc_release_version.py

示例12: describe

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def describe(self):
        repo = Git(self.path)
        cmd = ['git', 'describe', '--tags']
        result = repo.execute(cmd).split('-')

        if (len(result) == 1):
            return '', 0, ''
        else:
            howmany, sha = result[-2:]
            branch = '-'.join(result[0:len(result) - 2])
            return branch, howmany, sha
开发者ID:Doula,项目名称:Bambino,代码行数:13,代码来源:appenv.py

示例13: processCommitHook

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def processCommitHook(self, req):
        self.env.log.debug("processCommitHook")
        status = self.closestatus
        if not status:
            status = 'closed'

        data = req.args.get('payload')
         
        if data:
            jsondata = simplejson.loads(data)

            for i in jsondata['commits']:
                self.hook.process(i, status)


        if self.autofetch:
            repo = Git(self.repo)

            try:
              repo.execute(['git', 'fetch'])
            except:
              self.env.log.debug("git fetch failed!")
开发者ID:GunioRobot,项目名称:github-trac,代码行数:24,代码来源:github.py

示例14: processCommitHook

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def processCommitHook(self, req):
        self.env.log.debug("processCommitHook")
        status = self.closestatus
        if not status:
            status = "closed"

        data = req.args.get("payload")

        if data:
            jsondata = simplejson.loads(data)

            branch = jsondata["ref"][11:]
            #            if (branch == 'master') or branch.startswith('fixes/'):
            for i in jsondata["commits"]:
                self.hook.process(i, status, branch)

        if self.autofetch:
            repo = Git(self.repo)

            try:
                repo.execute(["git", "fetch"])
            except:
                self.env.log.debug("git fetch failed!")
开发者ID:nilknarf0,项目名称:extras,代码行数:25,代码来源:github.py

示例15: processCommitHook

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import execute [as 别名]
    def processCommitHook(self, req):
        self.env.log.debug("processCommitHook")
        status = self.closestatus
        if not status:
            status = 'closed'

        data = req.args.get('payload')

        if data:
            jsondata = simplejson.loads(data)

            for i in jsondata['commits']:
                self.hook.process(i, status, self.enable_revmap)

        if int(self.autofetch):
            repo = Git(self.repo)

            try:
              repo.execute(['git', 'fetch'])
            except:
              self.env.log.debug("git fetch failed!")

        self.env.log.debug("Redirect URL: %s" % req)
        req.redirect(self.browser)
开发者ID:azatoth,项目名称:github-trac,代码行数:26,代码来源:github.py


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