Skip to content

Commit

Permalink
Remove repo call (#69)
Browse files Browse the repository at this point in the history
* update dependencies
* remove a call to get GitHub repo
  • Loading branch information
beliaev-maksim authored Dec 19, 2024
1 parent 1614ff2 commit 63bddd2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local_settings.py
db.sqlite3
db.sqlite3-journal
media
venv
venv*
admin
grappelli
rest_framework
Expand Down
8 changes: 5 additions & 3 deletions github_jira_sync_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from github import Github
from github import GithubException
from github import GithubIntegration
from github import Issue
from github.Issue import Issue
from github.Repository import Repository
from jira import JIRA
from mistletoe import Document # type: ignore[import]
from mistletoe.contrib.jira_renderer import JIRARenderer # type: ignore[import]
Expand Down Expand Up @@ -206,7 +207,8 @@ async def bot(request: Request, payload: dict = Body(...)):
git_integration.get_repo_installation(owner, repo_name).id
).token
)
repo = git_connection.get_repo(f"{owner}/{repo_name}")
repo = Repository(git_connection.requester, {}, payload["repository"], completed=True)
repo_name = f"{owner}/{repo_name}"
try:
contents = repo.get_contents(".github/.jira_sync_config.yaml")
settings_content = contents.decoded_content # type: ignore[union-attr]
Expand Down Expand Up @@ -236,7 +238,7 @@ async def bot(request: Request, payload: dict = Body(...)):
logger.warning(f"{repo_name}: {msg}")
return {"msg": msg}

gh_issue = Issue.Issue(repo._requester, {}, payload["issue"], completed=True)
gh_issue = Issue(git_connection.requester, {}, payload["issue"], completed=True)

labels = settings["labels"] or []
allowed_labels = [str(label).lower() for label in labels]
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ dynamic = ["version"]
dependencies = [
"fastapi==0.115.6",
"pyyaml==6.0.2",
"pygithub==1.59.0",
"uvicorn[standard]==0.22.0",
"pygithub==2.5.0",
"uvicorn[standard]==0.34.0",
"load_dotenv==0.1.0",
"jira==3.5.0",
"jira==3.8.0",
"mistletoe==1.0.1",
"types-PyYAML"
]
Expand Down
7 changes: 0 additions & 7 deletions tests/unit/url_responses/github_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,3 @@ responses:
method: POST
status: 201
url: https://api.github.com:443/app/installations/35534068/access_tokens
- response:
auto_calculate_content_length: false
body: '{"id":602008644,"node_id":"R_kgDOI-HsRA","name":"test-ci","full_name":"beliaev-maksim/test-ci","private":false,"owner":{"login":"beliaev-maksim","id":51964909,"node_id":"MDQ6VXNlcjUxOTY0OTA5","avatar_url":"https://avatars.githubusercontent.com/u/51964909?v=4","gravatar_id":"","url":"https://api.github.com/users/beliaev-maksim","html_url":"https://github.com/beliaev-maksim","followers_url":"https://api.github.com/users/beliaev-maksim/followers","following_url":"https://api.github.com/users/beliaev-maksim/following{/other_user}","gists_url":"https://api.github.com/users/beliaev-maksim/gists{/gist_id}","starred_url":"https://api.github.com/users/beliaev-maksim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beliaev-maksim/subscriptions","organizations_url":"https://api.github.com/users/beliaev-maksim/orgs","repos_url":"https://api.github.com/users/beliaev-maksim/repos","events_url":"https://api.github.com/users/beliaev-maksim/events{/privacy}","received_events_url":"https://api.github.com/users/beliaev-maksim/received_events","type":"User","site_admin":false},"html_url":"https://github.com/beliaev-maksim/test-ci","description":null,"fork":false,"url":"https://api.github.com/repos/beliaev-maksim/test-ci","forks_url":"https://api.github.com/repos/beliaev-maksim/test-ci/forks","keys_url":"https://api.github.com/repos/beliaev-maksim/test-ci/keys{/key_id}","collaborators_url":"https://api.github.com/repos/beliaev-maksim/test-ci/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/beliaev-maksim/test-ci/teams","hooks_url":"https://api.github.com/repos/beliaev-maksim/test-ci/hooks","issue_events_url":"https://api.github.com/repos/beliaev-maksim/test-ci/issues/events{/number}","events_url":"https://api.github.com/repos/beliaev-maksim/test-ci/events","assignees_url":"https://api.github.com/repos/beliaev-maksim/test-ci/assignees{/user}","branches_url":"https://api.github.com/repos/beliaev-maksim/test-ci/branches{/branch}","tags_url":"https://api.github.com/repos/beliaev-maksim/test-ci/tags","blobs_url":"https://api.github.com/repos/beliaev-maksim/test-ci/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/beliaev-maksim/test-ci/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/beliaev-maksim/test-ci/git/refs{/sha}","trees_url":"https://api.github.com/repos/beliaev-maksim/test-ci/git/trees{/sha}","statuses_url":"https://api.github.com/repos/beliaev-maksim/test-ci/statuses/{sha}","languages_url":"https://api.github.com/repos/beliaev-maksim/test-ci/languages","stargazers_url":"https://api.github.com/repos/beliaev-maksim/test-ci/stargazers","contributors_url":"https://api.github.com/repos/beliaev-maksim/test-ci/contributors","subscribers_url":"https://api.github.com/repos/beliaev-maksim/test-ci/subscribers","subscription_url":"https://api.github.com/repos/beliaev-maksim/test-ci/subscription","commits_url":"https://api.github.com/repos/beliaev-maksim/test-ci/commits{/sha}","git_commits_url":"https://api.github.com/repos/beliaev-maksim/test-ci/git/commits{/sha}","comments_url":"https://api.github.com/repos/beliaev-maksim/test-ci/comments{/number}","issue_comment_url":"https://api.github.com/repos/beliaev-maksim/test-ci/issues/comments{/number}","contents_url":"https://api.github.com/repos/beliaev-maksim/test-ci/contents/{+path}","compare_url":"https://api.github.com/repos/beliaev-maksim/test-ci/compare/{base}...{head}","merges_url":"https://api.github.com/repos/beliaev-maksim/test-ci/merges","archive_url":"https://api.github.com/repos/beliaev-maksim/test-ci/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/beliaev-maksim/test-ci/downloads","issues_url":"https://api.github.com/repos/beliaev-maksim/test-ci/issues{/number}","pulls_url":"https://api.github.com/repos/beliaev-maksim/test-ci/pulls{/number}","milestones_url":"https://api.github.com/repos/beliaev-maksim/test-ci/milestones{/number}","notifications_url":"https://api.github.com/repos/beliaev-maksim/test-ci/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/beliaev-maksim/test-ci/labels{/name}","releases_url":"https://api.github.com/repos/beliaev-maksim/test-ci/releases{/id}","deployments_url":"https://api.github.com/repos/beliaev-maksim/test-ci/deployments","created_at":"2023-02-15T09:57:53Z","updated_at":"2023-05-15T09:25:41Z","pushed_at":"2023-05-15T09:29:16Z","git_url":"git://github.com/beliaev-maksim/test-ci.git","ssh_url":"[email protected]:beliaev-maksim/test-ci.git","clone_url":"https://github.com/beliaev-maksim/test-ci.git","svn_url":"https://github.com/beliaev-maksim/test-ci","homepage":null,"size":10,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":null,"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"master","permissions":{"admin":false,"maintain":false,"push":false,"triage":false,"pull":false},"temp_clone_token":"","network_count":0,"subscribers_count":1}'
content_type: text/plain
method: GET
status: 200
url: https://api.github.com:443/repos/beliaev-maksim/test-ci

0 comments on commit 63bddd2

Please sign in to comment.