|
4 | 4 |
|
5 | 5 | from click import Path as PathType
|
6 | 6 | from click import command, option, secho
|
7 |
| -from github import GithubIntegration |
8 |
| -from github.Auth import AppAuth |
9 | 7 |
|
10 | 8 | from ..dtos import Tree
|
11 |
| -from ..local import read_commit, read_repo |
12 |
| -from ..remote import write_commit |
| 9 | +from ..local import extract_repo_name, read_commit, read_repo |
| 10 | +from ..remote import authenticate_app, write_commit |
13 | 11 |
|
14 | 12 |
|
15 | 13 | def print_tree(tree: Tree, parent: Path, depth: int = 0) -> None:
|
@@ -86,23 +84,20 @@ def read(
|
86 | 84 | )
|
87 | 85 | def write(
|
88 | 86 | *,
|
89 |
| - application_id: str, |
| 87 | + application_id: int, |
90 | 88 | private_key: str,
|
91 | 89 | repo_path: Path,
|
92 | 90 | ref: str,
|
93 | 91 | ) -> None:
|
94 | 92 | basic_config(level=INFO)
|
95 | 93 |
|
96 | 94 | repo = read_repo(repo_path)
|
| 95 | + repo_name = extract_repo_name(repo) |
97 | 96 |
|
98 |
| - # TODO: parse repo.remote().url to get GitHub information |
99 |
| - # print(repo.remote().url) |
100 |
| - auth = AppAuth(application_id, private_key) |
101 |
| - integration = GithubIntegration(auth=auth) |
102 |
| - installation = integration.get_installations()[0] |
103 |
| - github = installation.get_github_for_installation() |
104 |
| - repository = github.get_repo("lettuce-financial/github-bot-signed-commit") |
| 97 | + github = authenticate_app(application_id, private_key) |
| 98 | + repository = github.get_repo(repo_name) |
105 | 99 |
|
106 | 100 | commit = read_commit(repo, ref)
|
107 | 101 | git_commit = write_commit(repository, commit)
|
| 102 | + |
108 | 103 | secho(f"Created git commit: {git_commit.sha}", fg="green")
|
0 commit comments