From 0490417eca7b007699c12ce963b053d4daa2970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Mon, 18 Jan 2021 12:57:36 +0100 Subject: [PATCH 1/2] fix private organization repositories --- addons/github-integration/plugin.cfg | 2 +- .../github-integration/scripts/ContributorClass.gd | 2 +- addons/github-integration/scripts/RepositoryItem.gd | 1 + addons/github-integration/scripts/RestHandler.gd | 10 ++++++++-- addons/github-integration/scripts/UserPanel.gd | 12 +++++++++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/addons/github-integration/plugin.cfg b/addons/github-integration/plugin.cfg index c0260ef..9fe67cb 100644 --- a/addons/github-integration/plugin.cfg +++ b/addons/github-integration/plugin.cfg @@ -3,5 +3,5 @@ name="GitHub integration" description="Plugin to integrate GitHub requests directly via Godot Engine Editor" author="Nicolo (fenix) Santilio" -version="1.3.9c" +version="1.4.0" script="scripts/github-integration.gd" diff --git a/addons/github-integration/scripts/ContributorClass.gd b/addons/github-integration/scripts/ContributorClass.gd index 4e49466..36abc34 100644 --- a/addons/github-integration/scripts/ContributorClass.gd +++ b/addons/github-integration/scripts/ContributorClass.gd @@ -37,7 +37,7 @@ func set_contributor_avatar(a : String) -> void: is_downloading = true func _process(delta): - if is_downloading: print(client.get_downloaded_bytes()/client.get_body_size()*100, " %") + if is_downloading: pass#print(client.get_downloaded_bytes()/client.get_body_size()*100, " %") func _on_request_completed(result: int, response_code: int, headers: PoolStringArray, avatar: PoolByteArray) -> void: if result == 0: diff --git a/addons/github-integration/scripts/RepositoryItem.gd b/addons/github-integration/scripts/RepositoryItem.gd index 8fcfe52..5a7d0bc 100644 --- a/addons/github-integration/scripts/RepositoryItem.gd +++ b/addons/github-integration/scripts/RepositoryItem.gd @@ -25,6 +25,7 @@ func _ready(): func set_repository(repository : Dictionary): _repository = repository _name = str(repository.name) + name = _name _stars = repository.stargazerCount _forks = repository.forkCount diff --git a/addons/github-integration/scripts/RestHandler.gd b/addons/github-integration/scripts/RestHandler.gd index 4b8cc3e..ef6053c 100644 --- a/addons/github-integration/scripts/RestHandler.gd +++ b/addons/github-integration/scripts/RestHandler.gd @@ -40,9 +40,10 @@ var loading : Control var session : HTTPClient = HTTPClient.new() var graphql_endpoint : String = "https://api.github.com/graphql" var graphql_queries : Dictionary = { - 'repositories':'{user(login: "%s"){repositories(ownerAffiliations:%s, first:%d, orderBy: {field: NAME, direction: ASC}){ nodes { diskUsage name owner { login } description url isFork isPrivate forkCount stargazerCount isInOrganization collaborators(affiliation: DIRECT, first: 100) { nodes {login name avatarUrl} } mentionableUsers(first: 100){ nodes{ login name avatarUrl } } defaultBranchRef { name } refs(refPrefix: "refs/heads/", first: 100){ nodes{ name target { ... on Commit { oid tree { oid } zipballUrl tarballUrl } } } } } } } }', + 'repositories':'{user(login: "%s"){repositories(ownerAffiliations:%s, first:%d, orderBy: {field: NAME, direction: ASC}){ nodes { diskUsage name owner { login } description url isFork isPrivate forkCount stargazerCount isInOrganization collaborators(affiliation: DIRECT, first: 100) { nodes {login name avatarUrl} } mentionableUsers(first: 100){ nodes{ login name avatarUrl } } defaultBranchRef { name } refs(refPrefix: "refs/heads/", first: 100){ nodes{ name target { ... on Commit { oid tree { oid } zipballUrl tarballUrl } } } } } } %s } }', 'repository':'{user(login: "%s"){repository(name:"%s"){diskUsage name owner { login } description url isFork isPrivate forkCount stargazerCount isInOrganization collaborators(affiliation: DIRECT, first: 100) { nodes {login name avatarUrl} } mentionableUsers(first: 100){ nodes{ login name avatarUrl } } defaultBranchRef { name } refs(refPrefix: "refs/heads/", first: 100){ nodes{ name target { ... on Commit { oid tree { oid } zipballUrl tarballUrl }}}}}}}', 'gists':'{ user(login: "%s") { gists(first: %s, orderBy: {field: PUSHED_AT, direction: DESC}, privacy: ALL) { nodes { owner { login } id description resourcePath name stargazerCount isPublic isFork files { encodedName encoding extension name size text } } } } }', + 'organizations_repositories':'organizations(first:10){nodes{repositories(first:100){nodes{diskUsage name owner { login } description url isFork isPrivate forkCount stargazerCount isInOrganization collaborators(affiliation: DIRECT, first: 100) { nodes {login name avatarUrl} } mentionableUsers(first: 100){ nodes{ login name avatarUrl } } defaultBranchRef { name } refs(refPrefix: "refs/heads/", first: 100){ nodes{ name target { ... on Commit { oid tree { oid } zipballUrl tarballUrl } } } } }}}}' } var header : PoolStringArray = ["Authorization: token "] var api_endpoints : Dictionary = { @@ -217,7 +218,12 @@ func request_contributor_avatar(avatar_url : String, contributor_class : Contrib func request_user_repositories() -> void: requesting = REQUESTS.USER_REPOSITORIES - var query : String = graphql_queries.repositories % [UserData.USER.login,PluginSettings.owner_affiliations, repositories_limit] + var owner_affiliations : Array = PluginSettings.owner_affiliations.duplicate(true) + var is_org_member : bool = false + if owner_affiliations.has("ORGANIZATION_MEMBER"): + owner_affiliations.erase("ORGANIZATION_MEMBER") + is_org_member = true + var query : String = graphql_queries.repositories % [UserData.USER.login, owner_affiliations, repositories_limit, graphql_queries.organizations_repositories if is_org_member else ""] client.request(graphql_endpoint, UserData.header, true, HTTPClient.METHOD_POST, print_query(query)) func request_user_repository(repository_owner : String, repository_name : String) -> void: diff --git a/addons/github-integration/scripts/UserPanel.gd b/addons/github-integration/scripts/UserPanel.gd index 0dfa60c..72d105d 100644 --- a/addons/github-integration/scripts/UserPanel.gd +++ b/addons/github-integration/scripts/UserPanel.gd @@ -81,7 +81,10 @@ func _on_request_failed(request_code : int, error_body : Dictionary) -> void: get_parent().print_debug_message("ERROR "+str(request_code)+" : "+error_body.message) func _on_user_repositories_requested(body : Dictionary) -> void: - var repositories : Array = body.user.repositories.nodes + var repositories : Array = body.user.repositories.nodes + if PluginSettings.owner_affiliations.has("ORGANIZATION_MEMBER"): + for organization in body.user.organizations.nodes: + repositories += organization.repositories.nodes load_repositories(repositories) func _on_user_gists_requested(body : Dictionary) -> void: @@ -113,6 +116,13 @@ func load_repositories(repositories : Array) -> void: clear_repo_list() for repository in repositories: + var is_listed : bool = false + for repository_item in repository_list: + if repository_item.name == repository.name: + is_listed = true + continue + if is_listed: + continue var repo_item = _repository_item.instance() RepoList.add_child(repo_item) repo_item.set_repository(repository) From 4711e8a8177a7f415612b725aeb014f954df04a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Mon, 18 Jan 2021 12:58:45 +0100 Subject: [PATCH 2/2] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5c7ddf..e65a880 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This plugin is now supported in [Godot Extended Library Discord](https://discord A complete GitHub integration for your Godot Editor! Manage your project without even opening your browser. Author: *"Nicolo (fenix) Santilio"* -Version: *1.3.9c* +Version: *1.4.0* Wiki: *[supported](https://github.com/fenix-hub/godot-engine.github-integration/wiki)* Godot Version: *3.2.3stable*