Skip to content

Commit 8d65e56

Browse files
authored
Merge pull request #88 from fenix-hub/dev
update v1.4.3
2 parents cc67a04 + 4074d5d commit 8d65e56

File tree

6 files changed

+292
-295
lines changed

6 files changed

+292
-295
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ This plugin is now supported in [Godot Extended Library Discord](https://discord
1212
A complete GitHub integration for your Godot Editor! Manage your project without even opening your browser.
1313

1414
Author: *"Nicolo (fenix) Santilio"*
15-
Version: *1.4.1*
16-
Godot Version: *3.2.3stable*
15+
Version: *1.4.3*
16+
Godot Version: *3.2.4-rc3*
1717
Wiki: *[supported](https://github.com/fenix-hub/godot-engine.github-integration/wiki)*
1818

1919
<img align="center" src="addons/github-integration/screenshots/banner.png">

addons/github-integration/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="GitHub integration"
44
description="Plugin to integrate GitHub requests directly via Godot Engine Editor"
55
author="Nicolo (fenix) Santilio"
6-
version="1.4.1"
6+
version="1.4.3"
77
script="scripts/github-integration.gd"

addons/github-integration/scripts/Commit.gd

Lines changed: 100 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ var IGNORE_FOLDERS : PoolStringArray = []
6767

6868
var current_handled_file : String
6969

70+
var commit_progress : float = 0
71+
7072
signal blob_created()
7173

7274
signal latest_commit()
@@ -155,7 +157,7 @@ func request_completed(result, response_code, headers, body ):
155157
match response_code:
156158
201:
157159
list_file_sha.append(JSON.parse(body.get_string_from_utf8()).result.sha)
158-
get_parent().print_debug_message("blobbed file")
160+
get_parent().print_debug_message("blobbed file (progress: {progress}%)".format({progress = commit_progress as int}))
159161
# OS.delay_msec(1000)
160162
emit_signal("file_blobbed")
161163
400:
@@ -321,43 +323,45 @@ func request_base_tree():
321323
request_blobs()
322324

323325
func request_blobs():
324-
requesting = REQUESTS.BLOB
325-
list_file_sha.clear()
326-
for file in files:
327-
current_handled_file = file
328-
if list_file_size[files.find(file)] < 104857600:
329-
var content = ""
330-
var sha = "" # is set to update a file
331-
var encoding = ""
332-
333-
var f : File = File.new()
334-
f.open(file,File.READ)
335-
content = Marshalls.raw_to_base64(f.get_buffer(f.get_len()))
336-
encoding = "base64"
337-
f.close()
338-
339-
get_parent().print_debug_message("blobbing ~> "+file.get_file())
340-
341-
var bod = {
342-
"content":content,
343-
"encoding":encoding,
344-
}
345-
346-
new_repo.request("https://api.github.com/repos/"+repo_selected.owner.login+"/"+repo_selected.name+"/git/blobs",
347-
UserData.header,false,HTTPClient.METHOD_POST,JSON.print(bod))
348-
yield(self,"file_blobbed")
349-
else:
350-
get_parent().print_debug_message("pointing large file, please wait...")
351-
var output = []
352-
OS.execute( 'git', [ "lfs", "pointer",'--file',ProjectSettings.globalize_path(file)], true, output )
353-
var oid : String = output[0].split(":",false)[2]
354-
var onlyoid : String = oid.rstrip("size").split(" ")[0].replace("\nsize","")
355-
list_file_sha.append(onlyoid)
356-
Progress.set_value(range_lerp(files.find(file),0,files.size(),0,100))
357-
358-
get_parent().print_debug_message("blobbed each file with success, start committing...")
359-
Progress.set_value(100)
360-
request_commit_tree()
326+
requesting = REQUESTS.BLOB
327+
list_file_sha.clear()
328+
for file in files:
329+
current_handled_file = file
330+
if list_file_size[files.find(file)] < 104857600:
331+
var content = ""
332+
var sha = "" # is set to update a file
333+
var encoding = ""
334+
335+
var f : File = File.new()
336+
f.open(file,File.READ)
337+
content = Marshalls.raw_to_base64(f.get_buffer(f.get_len()))
338+
encoding = "base64"
339+
f.close()
340+
341+
get_parent().print_debug_message("blobbing ~> "+file.get_file())
342+
343+
var bod = {
344+
"content":content,
345+
"encoding":encoding,
346+
}
347+
348+
new_repo.request("https://api.github.com/repos/"+repo_selected.owner.login+"/"+repo_selected.name+"/git/blobs",
349+
UserData.header,false,HTTPClient.METHOD_POST,JSON.print(bod))
350+
yield(self,"file_blobbed")
351+
else:
352+
get_parent().print_debug_message("pointing large file, please wait...")
353+
var output = []
354+
OS.execute( 'git', [ "lfs", "pointer",'--file',ProjectSettings.globalize_path(file)], true, output )
355+
var oid : String = output[0].split(":",false)[2]
356+
var onlyoid : String = oid.rstrip("size").split(" ")[0].replace("\nsize","")
357+
list_file_sha.append(onlyoid)
358+
commit_progress = range_lerp(files.find(file),0,files.size(),0,100)
359+
Progress.set_value(commit_progress)
360+
361+
get_parent().print_debug_message("blobbed each file with success, start committing...")
362+
Progress.set_value(100)
363+
commit_progress = 0
364+
request_commit_tree()
361365

362366
func request_commit_tree():
363367
requesting = REQUESTS.NEW_TREE
@@ -481,83 +485,80 @@ func on_confirm():
481485
pass
482486

483487
func on_files_selected(paths : PoolStringArray):
484-
for path in paths:
485-
if not files.has(path):
486-
files.append(path)
487-
else:
488-
files.erase(path)
489-
490-
show_files(paths,true,false)
488+
for path in paths:
489+
if not files.has(path):
490+
files.append(path)
491+
492+
show_files(files,true,false)
491493

492494
func on_dir_selected(path : String):
493-
var directories = []
494-
var dir = Directory.new()
495-
dir.open(path)
496-
dir.list_dir_begin(true,false)
497-
var file = dir.get_next()
498-
while (file != ""):
499-
if dir.current_is_dir():
500-
var directorypath = dir.get_current_dir()+"/"+file
501-
directories.append(directorypath)
502-
else:
503-
var filepath = dir.get_current_dir()+"/"+file
504-
if not files.has(filepath):
505-
files.append(filepath)
506-
507-
file = dir.get_next()
508-
509-
dir.list_dir_end()
510-
511-
show_files(files,true,false)
512-
513-
for directory in directories:
514-
on_dir_selected(directory)
495+
if ".git" in path:
496+
printerr("Cannot commit '.git' folders.")
497+
return
498+
var directories = []
499+
var dir = Directory.new()
500+
dir.open(path)
501+
dir.list_dir_begin(true,false)
502+
var file = dir.get_next()
503+
while (file != ""):
504+
if dir.current_is_dir():
505+
var directorypath = dir.get_current_dir()+"/"+file
506+
directories.append(directorypath)
507+
else:
508+
var filepath = dir.get_current_dir()+"/"+file
509+
if not files.has(filepath):
510+
files.append(filepath)
511+
512+
file = dir.get_next()
513+
514+
dir.list_dir_end()
515+
516+
for directory in directories:
517+
on_dir_selected(directory)
518+
519+
show_files(files,true,false)
515520

516521
func show_files(paths : PoolStringArray, isfile : bool = false , isdir : bool = false):
517-
Uncommitted.clear()
518-
519-
for file in paths:
520-
file = file.replace("///","//")
521-
if isfile:
522-
Uncommitted.add_item(file,IconLoaderGithub.load_icon_from_name("file-gray"))
523-
524-
# if isdir:
525-
# for dir in paths:
526-
# Uncommitted.add_item(dir,IconLoaderGithub.load_icon_from_name("dir"))
522+
Uncommitted.clear()
523+
524+
for file in paths:
525+
file = file.replace("///","//")
526+
if isfile:
527+
Uncommitted.add_item(file,IconLoaderGithub.load_icon_from_name("file-gray"))
527528

528529
func on_removefile_pressed():
529-
var filestoremove = Uncommitted.get_selected_items()
530-
if filestoremove.size() == 0:
531-
on_nothing_selected()
532-
return
533-
var first_file = filestoremove[0]
534-
var file_name = Uncommitted.get_item_text(first_file)
535-
files.erase(file_name)
536-
Uncommitted.remove_item(first_file)
537-
if Uncommitted.get_selected_items().size() > 0:
538-
on_removefile_pressed()
539-
else:
540-
on_nothing_selected()
530+
var filestoremove = Uncommitted.get_selected_items()
531+
if filestoremove.size() == 0:
532+
on_nothing_selected()
533+
return
534+
var first_file = filestoremove[0]
535+
var file_name = Uncommitted.get_item_text(first_file)
536+
files.erase(file_name)
537+
Uncommitted.remove_item(first_file)
538+
if Uncommitted.get_selected_items().size() > 0:
539+
on_removefile_pressed()
540+
else:
541+
on_nothing_selected()
541542

542543
func on_selectfiles_pressed():
543-
SelectFiles.set_mode(FileDialog.MODE_OPEN_FILES)
544-
SelectFiles.invalidate()
545-
SelectFiles.popup()
544+
SelectFiles.set_mode(FileDialog.MODE_OPEN_FILES)
545+
SelectFiles.invalidate()
546+
SelectFiles.popup()
546547

547548
func on_selectdirectory_pressed():
548-
SelectFiles.set_mode(FileDialog.MODE_OPEN_DIR)
549-
SelectFiles.invalidate()
550-
SelectFiles.popup()
549+
SelectFiles.set_mode(FileDialog.MODE_OPEN_DIR)
550+
SelectFiles.invalidate()
551+
SelectFiles.popup()
551552

552553
func on_item_selected(idx : int):
553-
removefileBtn.set_disabled(false)
554+
removefileBtn.set_disabled(false)
554555

555556
func on_multiple_item_selected(idx : int, selected : bool):
556-
removefileBtn.set_disabled(false)
557+
removefileBtn.set_disabled(false)
557558

558559
func on_nothing_selected():
559-
removefileBtn.set_disabled(true)
560+
removefileBtn.set_disabled(true)
560561

561562
func about_gitignore_pressed():
562-
OS.shell_open("https://git-scm.com/docs/gitignore")
563+
OS.shell_open("https://git-scm.com/docs/gitignore")
563564

0 commit comments

Comments
 (0)