Skip to content

Commit

Permalink
[Refactor] Pass github config as prop (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
seyLu authored Sep 1, 2023
1 parent f5b8b5d commit 717a466
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# logging
debug.log
debug.log.*
log/*
!log/.gitignore

# VS Code config
.vscode/
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ cp .env.example .env

```bash
GITHUB_PERSONAL_ACCESS_TOKEN=<your_github_personal_access_token>
GITHUB_USERNAME=<your_github_username>
GITHUB_REPO_OWNER=<target_github_repository_owner>
GITHUB_REPO_NAME=<target_github_repository_name>
```
Expand Down
2 changes: 2 additions & 0 deletions log/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 1 addition & 1 deletion logging.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interval=midnight
backupCount=5
formatter=verbose
level=WARNING
args=('debug.log',)
args=('log/debug.log',)

[handler_screen]
class=StreamHandler
Expand Down
10 changes: 6 additions & 4 deletions scripts/setup_issue_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ class LabelFile:
@dataclass(frozen=True)
class GithubConfig:
PERSONAL_ACCESS_TOKEN: str = validate_env("GITHUB_PERSONAL_ACCESS_TOKEN")
USERNAME: str = validate_env("GITHUB_USERNAME")
REPO_OWNER: str = validate_env("GITHUB_REPO_OWNER")
REPO_NAME: str = validate_env("GITHUB_REPO_NAME")


class GithubIssueLabel:
def __init__(self) -> None:
self._url: str = f"https://api.github.com/repos/{GithubConfig.REPO_OWNER}/{GithubConfig.REPO_NAME}/labels"
def __init__(self, github_config: GithubConfig | None = None) -> None:
if github_config is None:
github_config = GithubConfig()

self._url: str = f"https://api.github.com/repos/{github_config.REPO_OWNER}/{github_config.REPO_NAME}/labels"
self._headers: dict[str, str] = {
"Authorization": f"Bearer {GithubConfig.PERSONAL_ACCESS_TOKEN}",
"Authorization": f"Bearer {github_config.PERSONAL_ACCESS_TOKEN}",
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
}
Expand Down

0 comments on commit 717a466

Please sign in to comment.