Skip to content

Commit

Permalink
Release version 0.0.0.dev47
Browse files Browse the repository at this point in the history
  • Loading branch information
AAriam committed Nov 13, 2024
1 parent 494a59b commit 149ba64
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespaces = true
# ----------------------------------------- Project Metadata -------------------------------------
#
[project]
version = "0.0.0.dev46"
version = "0.0.0.dev47"
name = "PyLinks"
dependencies = [
"requests >= 2.31.0, < 3",
"ExceptionMan == 0.0.0.dev33",
"MDit == 0.0.0.dev33",
"ExceptionMan == 0.0.0.dev34",
"MDit == 0.0.0.dev34",
]
requires-python = ">=3.10"

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests >= 2.31.0, < 3
ExceptionMan == 0.0.0.dev33
MDit == 0.0.0.dev33
ExceptionMan == 0.0.0.dev34
MDit == 0.0.0.dev34
37 changes: 26 additions & 11 deletions src/pylinks/api/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ def _rest_query(
endpoint=endpoint
)

def _graphql_query(
self,
payload: str,
extra_headers: dict | None = None,
) -> dict:
return self._github.graphql_query(
query=f'repository(name: "{self._name}", owner: "{self._username}") {{{payload}}}',
extra_headers=extra_headers,
)["repository"]

@property
def username(self) -> str:
return self._username
Expand Down Expand Up @@ -412,13 +422,9 @@ def discussion_categories(self) -> list[dict[str, str]]:
- [GitHub Docs](https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions)
-
"""
payload = "{discussionCategories(first: 100) {edges {node {name, slug, id}}}}"
query = f'repository(name: "{self._name}", owner: "{self._username}") {payload}'
data = self._github.graphql_query(query)
discussions = [
entry["node"]
for entry in data["repository"]["discussionCategories"]["edges"]
]
payload = "discussionCategories(first: 100) {edges {node {name, slug, id}}}"
data = self._graphql_query(payload)
discussions = [entry["node"] for entry in data["discussionCategories"]["edges"]]
return discussions

def issue(self, number: int) -> dict:
Expand Down Expand Up @@ -610,7 +616,12 @@ def pull(self, number: int) -> dict:
"""
return self._rest_query(f"pulls/{number}")

def pull_commits(self, number: int) -> list[dict]:
def pull_commits(
self,
number: int,
count: int = 0,
sort: Literal["first", "last"] = "last",
) -> list[dict]:
"""
Get a list of commits for a pull request.
Expand All @@ -629,6 +640,9 @@ def pull_commits(self, number: int) -> list[dict]:
----------
- [GitHub API Docs](https://docs.github.com/en/rest/pulls/commits?apiVersion=2022-11-28#list-commits-on-a-pull-request)
"""
payload = f"pullRequest(number: {number})"
commits = "{{commits()"

commits = []
page = 1
while True:
Expand All @@ -639,6 +653,8 @@ def pull_commits(self, number: int) -> list[dict]:
break
return commits



def pull_create(
self,
head: str,
Expand Down Expand Up @@ -1683,9 +1699,8 @@ def branch_protection_rules(self) -> list[dict]:
----------
- [GitHub API Docs](https://docs.github.com/en/graphql/reference/objects#branchprotectionruleconnection)
"""
payload = "{branchProtectionRules(first: 100) {nodes {id, pattern}}}"
query = f'repository(name: "{self._name}", owner: "{self._username}") {payload}'
data = self._github.graphql_query(query)
payload = "branchProtectionRules(first: 100) {nodes {id, pattern}}"
data = self._graphql_query(payload)
return data["repository"]["branchProtectionRules"]["nodes"]

def branch_protection_rule_create(
Expand Down

0 comments on commit 149ba64

Please sign in to comment.