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


Python Git.fetch方法代码示例

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


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

示例1: on_message

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import fetch [as 别名]
async def on_message(message):
	if client.sleeping:
		if message.content == '!wake':
			client.sleeping = False
			await client.send_message(message.channel, 'SolBot online!')
	else:
		if message.content == '!sleep':
			client.sleeping = True
			await client.send_message(message.channel, 'Going to sleep...')
		elif message.content == '!update':
			g = Git(os.path.dirname(os.path.abspath(__file__)))
			tmp = await client.send_message(message.channel, 'Pulling new code...')
			g.pull()
			await client.edit_message(tmp, 'Code pulled. Restarting...')
			client.logout()
			os.execv(sys.executable, ['python3.5'] + sys.argv)
		elif message.content == '!gitstatus':
			g = Git(os.path.dirname(os.path.abspath(__file__)))
			tmp = await client.send_message(message.channel, 'Checking status...')
			g.fetch()
			p = re.compile('Your branch is.*by (\d+) commits.*')
			m = p.match(g.status())
			if m:
				await client.edit_message(tmp, 'I am behind by {} commits'.format(m.group(1)))
			else:
				await client.edit_message(tmp, 'I am up to date!')
开发者ID:flip40,项目名称:SolBot,代码行数:28,代码来源:solbot.py

示例2: branches

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import fetch [as 别名]
def branches():
    g = Git(PROJECT_DIR)
    send('重新获取远程分支中.....')
    g.fetch(REMOTE_NAME)
    send('获取成功')
    branch_names = g.branch('-a').split('\n')
    return jsonify(branch_names)
开发者ID:barrysfinalhome,项目名称:pythonStudy,代码行数:9,代码来源:deploy_server.py

示例3: cloneOrCheckout

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import fetch [as 别名]
def cloneOrCheckout(base_path, repo):
	git = Git()
	repo_path = os.path.join(base_path, repo['name'])
	print (repo_path)
	try:
		os.chdir(repo_path)
	except OSError:
		os.chdir(base_path)
		git.clone(repo['base_url'] + repo['name'])
		os.chdir(repo_path)
		cloned = True
	finally:
		git.fetch()
		git.checkout(repo['branch'])
		os.chdir(base_path)
开发者ID:j-be,项目名称:vj-control-server-buildenv,代码行数:17,代码来源:checkout-repos.py

示例4: addSuperModuleCommit

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import fetch [as 别名]
	def addSuperModuleCommit(self, id, hash, url, who, branch, project):	
		self.log.debug("branch: " + branch + ", project:" + project)
		
		hasSuperModule = False
		isSuperModuleBr = False
		self.log.debug("Project names: " + str(self.config.projects))
		
		projectNames = self.config.projects.keys()
		for proj in projectNames:
				self.log.debug("project: " + project + " proj: " + proj)
				if project.lower() == proj:
					hasSuperModule = True
					break
	
		for br in self.config.branches:
			if branch == br:
				isSuperModuleBr = True
				break

		self.log.debug("isSuperModuleBr: " + str(isSuperModuleBr) + " hasSuperModule: " + str(hasSuperModule))	
		if isSuperModuleBr and hasSuperModule:
			self.log.debug("Git Profile Path: " + str(self.config.profile))
			git = Git(self.config.profile)
			self.checkoutTrackingBranch(git, branch)
			git.pull()
			git.submodule("update","--init")
			gitSubmoduleProfile = {'git':self.config.superRepoPath + self.config.projects[project.lower()]}
			gitSubmodule = Git(gitSubmoduleProfile)
			self.log.debug("checking out hash: " + hash)
			gitSubmodule.fetch()
	
			if self.isOptOut(gitSubmodule, hash):
				return	
	
			gitSubmodule.checkout(hash, True)
			git.add(".")
			commitMsg = "Auto checkin: " + self.getCommitMessage(gitSubmodule, hash) + "\nuser:" + who + "\nhash:" + hash + "\nproject: " + project
			self.log.debug("commiting in super module: " +  commitMsg)
			git.commit(commitMsg)
			self.log.debug("pushing super module to branch: " + branch)
			git.push(branch)
		else:
			self.log.debug("No super module commit is required.")
开发者ID:ralberts,项目名称:Gerrit-Submodule-Hooks,代码行数:45,代码来源:supermodulecommit.py

示例5: branch

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import fetch [as 别名]
def branch(branch_name):
    # branch_name = 'remotes/ssh/' + branch_name
    g = Git(PROJECT_DIR)
    send('重新获取远程分支中.....')
    g.fetch(REMOTE_NAME)
    send('获取成功')
    branch_names = g.branch('-a').split('\n')
    branch_names = [_.strip() for _ in branch_names]
    if branch_name not in branch_names:
        return '你的这个branch啊,鹅母鸡鸭'
    try:
        send('重置分支')
        g.reset('--hard')
        send('切换分支中')
        g.checkout(branch_name)
        send('切换分支完成')
    except Exception as e:
        return str(e)
    return branch_name
开发者ID:barrysfinalhome,项目名称:pythonStudy,代码行数:21,代码来源:deploy_server.py

示例6: GitWrapper

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import fetch [as 别名]

#.........这里部分代码省略.........

        yield stash

        if stashed[0]:
            print(colored('unstashing', 'magenta'))
            try:
                self._run('stash', 'pop')
            except GitError as e:
                raise UnstashError(stderr=e.stderr, stdout=e.stdout)

    def checkout(self, branch_name):
        """ Checkout a branch by name. """
        try:
            find(
                self.repo.branches, lambda b: b.name == branch_name
            ).checkout()
        except OrigCheckoutError as e:
            raise CheckoutError(branch_name, details=e)

    def rebase(self, target_branch):
        """ Rebase to target branch. """
        current_branch = self.repo.active_branch

        arguments = (
                ([self.config('git-up.rebase.arguments')] or []) +
                [target_branch.name]
        )
        try:
            self._run('rebase', *arguments)
        except GitError as e:
            raise RebaseError(current_branch.name, target_branch.name,
                              **e.__dict__)

    def fetch(self, *args, **kwargs):
        """ Fetch remote commits. """

        # Unlike the other git commands, we want to output `git fetch`'s
        # output in real time. Therefore we use a different implementation
        # from `GitWrapper._run` which buffers all output.
        # In theory this may deadlock if `git fetch` prints more than 8 KB
        # to stderr which is here assumed to not happen in day-to-day use.

        stdout = six.b('')

        # Execute command
        cmd = self.git.fetch(as_process=True, *args, **kwargs)

        # Capture output
        while True:
            output = cmd.stdout.read(1)

            sys.stdout.write(output.decode('utf-8'))
            sys.stdout.flush()

            stdout += output

            # Check for EOF
            if output == six.b(""):
                break

        # Wait for the process to quit
        try:
            cmd.wait()
        except GitCommandError as error:
            # Add more meta-information to errors
            message = "'{0}' returned exit status {1}".format(
开发者ID:msiemens,项目名称:PyGitUp,代码行数:70,代码来源:git_wrapper.py


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