Skip to content

Commit

Permalink
Merge pull request #85 from fenix-hub/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
fenix-hub authored Jan 18, 2021
2 parents df97d99 + 4711e8a commit e2e4406
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
2 changes: 1 addition & 1 deletion addons/github-integration/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion addons/github-integration/scripts/ContributorClass.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions addons/github-integration/scripts/RepositoryItem.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions addons/github-integration/scripts/RestHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion addons/github-integration/scripts/UserPanel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e2e4406

Please sign in to comment.