Merge pull request #139 from devchat-ai/github-username
feat: Add GitHub username retrieval function
This commit is contained in:
commit
4fdd536226
@ -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 common_util import assert_exit # noqa: E402
|
||||||
from git_api import (
|
from git_api import (
|
||||||
get_git_username,
|
|
||||||
get_github_repo,
|
get_github_repo,
|
||||||
get_github_repo_issues,
|
get_github_repo_issues,
|
||||||
|
get_github_username,
|
||||||
get_issue_info,
|
get_issue_info,
|
||||||
subprocess_check_output,
|
subprocess_check_output,
|
||||||
subprocess_run,
|
subprocess_run,
|
||||||
@ -433,9 +433,7 @@ def get_selected_issue_ids():
|
|||||||
Returns:
|
Returns:
|
||||||
list: 用户选中的issue id列表
|
list: 用户选中的issue id列表
|
||||||
"""
|
"""
|
||||||
name = get_git_username()
|
name = get_github_username()
|
||||||
if not name:
|
|
||||||
return
|
|
||||||
issue_repo = get_github_repo(True)
|
issue_repo = get_github_repo(True)
|
||||||
issues = get_github_repo_issues(issue_repo, assignee=name, state="open")
|
issues = get_github_repo_issues(issue_repo, assignee=name, state="open")
|
||||||
if issues:
|
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)
|
save_config_item(project_config_path, "last_base_branch", base_branch)
|
||||||
|
|
||||||
|
|
||||||
def get_git_username():
|
def get_github_username():
|
||||||
return subprocess_check_output(["git", "config", "--get", "user.name"]).decode("utf-8").strip()
|
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(
|
def get_github_repo_issues(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user