diff --git a/project.py b/project.py index 05924c6..989eb88 100644 --- a/project.py +++ b/project.py @@ -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: diff --git a/subcmds/config.py b/subcmds/config.py index 3f64ec4..ea7da0a 100644 --- a/subcmds/config.py +++ b/subcmds/config.py @@ -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: diff --git a/subcmds/gitee_pr.py b/subcmds/gitee_pr.py index 4296b56..2c228de 100644 --- a/subcmds/gitee_pr.py +++ b/subcmds/gitee_pr.py @@ -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'}