feat: Add GitHub username retrieval function
- Implement `get_github_username()` to fetch GitHub username via API - Update `get_selected_issue_ids()` to use GitHub username instead of git username - Enhance GitHub issue selection workflow with authenticated username retrieval
This commit is contained in:
parent
e8d960794c
commit
9490359c37
@ -13,9 +13,9 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
|
||||
|
||||
from common_util import assert_exit # noqa: E402
|
||||
from git_api import (
|
||||
get_git_username,
|
||||
get_github_repo,
|
||||
get_github_repo_issues,
|
||||
get_github_username,
|
||||
get_issue_info,
|
||||
subprocess_check_output,
|
||||
subprocess_run,
|
||||
@ -433,9 +433,7 @@ def get_selected_issue_ids():
|
||||
Returns:
|
||||
list: 用户选中的issue id列表
|
||||
"""
|
||||
name = get_git_username()
|
||||
if not name:
|
||||
return
|
||||
name = get_github_username()
|
||||
issue_repo = get_github_repo(True)
|
||||
issues = get_github_repo_issues(issue_repo, assignee=name, state="open")
|
||||
if issues:
|
||||
|
@ -538,8 +538,14 @@ def save_last_base_branch(base_branch=None):
|
||||
save_config_item(project_config_path, "last_base_branch", base_branch)
|
||||
|
||||
|
||||
def get_git_username():
|
||||
return subprocess_check_output(["git", "config", "--get", "user.name"]).decode("utf-8").strip()
|
||||
def get_github_username():
|
||||
url = f"{GITHUB_API_URL}/user"
|
||||
headers = {
|
||||
"Authorization": f"token {GITHUB_ACCESS_TOKEN}",
|
||||
"Accept": "application/vnd.github.v3+json",
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
return response.json()["login"]
|
||||
|
||||
|
||||
def get_github_repo_issues(
|
||||
|
Loading…
x
Reference in New Issue
Block a user