feat(config) add --global option

This commit is contained in:
江畅
2020-08-24 18:18:57 +08:00
parent 934f1c8fcd
commit 75a9490ad9
3 changed files with 14 additions and 4 deletions
+3 -1
View File
@@ -1434,7 +1434,9 @@ class Project(object):
namespace = self._GiteeNamespace()
token = self.manifest.manifestProject.config.GetString('repo.token')
if not token:
raise PullRequestError('repo.token is None, Please set it before pushing, you need `repo config -h`')
token = GitConfig.ForUser().GetString('repo.token')
if not token:
raise PullRequestError('repo.token is None, Please set it before pushing, you need `repo config -h`')
post_url = gitee_url + namespace + '/' + self.name + '/' + 'pulls'
pushurl = self.manifest.manifestProject.config.GetString('repo.pushurl')
if not pushurl:
+6
View File
@@ -33,6 +33,9 @@ class Config(Command):
p.add_option('--bool',
dest='bool', action='store_true',
help='git config will ensure that the output is "true" or "false"')
p.add_option('--global',
dest='Global', action='store_true',
help='git config use global config file')
def Execute(self, opt, args):
if not args:
@@ -53,6 +56,9 @@ class Config(Command):
if opt.bool:
command.append('--bool')
if opt.Global:
command.append('--global')
command.extend(args)
if GitCommand(mp, command).Wait() != 0:
+5 -3
View File
@@ -17,6 +17,7 @@ import sys
import requests
import json
from command import Command
from git_config import GitConfig
from git_command import GitCommand
from error import GitError
@@ -64,10 +65,11 @@ class GiteePr(Command):
sys.exit(1)
name_space = project._GiteeNamespace()
token = self.manifest.manifestProject.config.GetString('repo.token')
if not token:
sys.stderr.write('repo.token is None, Please set it, you need `repo config -h`\n')
sys.exit(1)
token = GitConfig.ForUser().GetString('repo.token')
if not token:
sys.stderr.write('repo.token is None, Please set it, you need `repo config -h`\n')
sys.exit(1)
p_list = {'project_name': project_name, 'base': base_branch, 'head': branch_name}
url = 'https://gitee.com/api/v5/repos/%s/%s/pulls' % (name_space, project_name)
payload = {'base': base_branch, 'head': branch_name, 'page': 0, 'access_token': token, 'state': 'open'}