mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-24 16:20:08 +01:00
Performance: don't create trees and blobs, only update repos once
This commit is contained in:
parent
cccaa75a48
commit
fe97283ddb
5 changed files with 16 additions and 21 deletions
|
@ -112,9 +112,6 @@ func construct():
|
||||||
continue
|
continue
|
||||||
game.global_shell.run("git remote add %s '%s'" % [r2, repos[r2].path])
|
game.global_shell.run("git remote add %s '%s'" % [r2, repos[r2].path])
|
||||||
|
|
||||||
# Allow receiving a push of the checked-out branch.
|
|
||||||
game.global_shell.run("git config receive.denyCurrentBranch ignore")
|
|
||||||
|
|
||||||
for r in repos:
|
for r in repos:
|
||||||
var repo = repos[r]
|
var repo = repos[r]
|
||||||
game.global_shell.cd(repo.path)
|
game.global_shell.cd(repo.path)
|
||||||
|
|
|
@ -102,7 +102,7 @@ func load_level(level_id):
|
||||||
terminal.clear()
|
terminal.clear()
|
||||||
terminal.find_node("TextEditor").close()
|
terminal.find_node("TextEditor").close()
|
||||||
|
|
||||||
update_repos()
|
#update_repos()
|
||||||
|
|
||||||
# Unmute the audio after a while, so that player can hear pop sounds for
|
# Unmute the audio after a while, so that player can hear pop sounds for
|
||||||
# nodes they create.
|
# nodes they create.
|
||||||
|
|
|
@ -179,11 +179,8 @@ size_flags_vertical = 3
|
||||||
margin_right = 633.0
|
margin_right = 633.0
|
||||||
margin_bottom = 60.0
|
margin_bottom = 60.0
|
||||||
rect_min_size = Vector2( 0, 60 )
|
rect_min_size = Vector2( 0, 60 )
|
||||||
size_flags_vertical = 3
|
|
||||||
size_flags_stretch_ratio = 0.0
|
|
||||||
custom_fonts/normal_font = ExtResource( 7 )
|
custom_fonts/normal_font = ExtResource( 7 )
|
||||||
text = "Level name here!"
|
text = "Level name here!"
|
||||||
fit_content_height = true
|
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
@ -191,14 +188,12 @@ __meta__ = {
|
||||||
[node name="Text" type="Control" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"]
|
[node name="Text" type="Control" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"]
|
||||||
margin_top = 65.0
|
margin_top = 65.0
|
||||||
margin_right = 633.0
|
margin_right = 633.0
|
||||||
margin_bottom = 464.0
|
margin_bottom = 264.0
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="LevelDescription" type="RichTextLabel" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel/Text"]
|
[node name="LevelDescription" type="RichTextLabel" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel/Text"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
margin_left = 0.943848
|
|
||||||
margin_right = 0.943848
|
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
bbcode_enabled = true
|
bbcode_enabled = true
|
||||||
bbcode_text = "Level description here!"
|
bbcode_text = "Level description here!"
|
||||||
|
@ -220,11 +215,10 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Goals" type="VBoxContainer" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"]
|
[node name="Goals" type="VBoxContainer" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"]
|
||||||
margin_top = 469.0
|
margin_top = 269.0
|
||||||
margin_right = 633.0
|
margin_right = 633.0
|
||||||
margin_bottom = 469.0
|
margin_bottom = 469.0
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
size_flags_stretch_ratio = 0.0
|
|
||||||
|
|
||||||
[node name="FileBrowser" parent="Rows/Columns/RightSide" instance=ExtResource( 5 )]
|
[node name="FileBrowser" parent="Rows/Columns/RightSide" instance=ExtResource( 5 )]
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
|
|
|
@ -46,6 +46,7 @@ func there_is_a_git():
|
||||||
return shell.run("test -d .git && echo yes || echo no") == "yes\n"
|
return shell.run("test -d .git && echo yes || echo no") == "yes\n"
|
||||||
|
|
||||||
func update_everything():
|
func update_everything():
|
||||||
|
print("update_everything()")
|
||||||
if there_is_a_git():
|
if there_is_a_git():
|
||||||
update_head()
|
update_head()
|
||||||
update_refs()
|
update_refs()
|
||||||
|
@ -65,8 +66,8 @@ func set_path(new_path):
|
||||||
for o in objects.values():
|
for o in objects.values():
|
||||||
o.queue_free()
|
o.queue_free()
|
||||||
objects = {}
|
objects = {}
|
||||||
if is_inside_tree():
|
# if is_inside_tree():
|
||||||
update_everything()
|
# update_everything()
|
||||||
|
|
||||||
func get_path():
|
func get_path():
|
||||||
return path
|
return path
|
||||||
|
@ -92,6 +93,10 @@ func update_objects():
|
||||||
|
|
||||||
var type = object_type(o)
|
var type = object_type(o)
|
||||||
|
|
||||||
|
if simplified_view:
|
||||||
|
if type == "tree" or type == "blob":
|
||||||
|
continue
|
||||||
|
|
||||||
var n = node.instance()
|
var n = node.instance()
|
||||||
n.id = o
|
n.id = o
|
||||||
n.type = object_type(o)
|
n.type = object_type(o)
|
||||||
|
@ -106,7 +111,7 @@ func update_objects():
|
||||||
n.content = n.content.replacen("\t", " ")
|
n.content = n.content.replacen("\t", " ")
|
||||||
"commit":
|
"commit":
|
||||||
var c = {}
|
var c = {}
|
||||||
c[commit_tree(o)] = ""
|
#c[commit_tree(o)] = ""
|
||||||
for p in commit_parents(o):
|
for p in commit_parents(o):
|
||||||
c[p] = ""
|
c[p] = ""
|
||||||
n.children = c
|
n.children = c
|
||||||
|
@ -121,10 +126,6 @@ func update_objects():
|
||||||
nodes.add_child(n)
|
nodes.add_child(n)
|
||||||
objects[o] = n
|
objects[o] = n
|
||||||
|
|
||||||
if simplified_view:
|
|
||||||
if type == "tree" or type == "blob":
|
|
||||||
n.hide()
|
|
||||||
|
|
||||||
func update_node_positions():
|
func update_node_positions():
|
||||||
if there_is_a_git():
|
if there_is_a_git():
|
||||||
var graph_text = shell.run("git log --graph --oneline --all --no-abbrev")
|
var graph_text = shell.run("git log --graph --oneline --all --no-abbrev")
|
||||||
|
@ -226,7 +227,8 @@ func update_head():
|
||||||
n.children = {ref_target("HEAD"): ""}
|
n.children = {ref_target("HEAD"): ""}
|
||||||
|
|
||||||
func all_objects():
|
func all_objects():
|
||||||
var obj = git("cat-file --batch-check='%(objectname)' --batch-all-objects", true)
|
#var obj = git("cat-file --batch-check='%(objectname)' --batch-all-objects", true)
|
||||||
|
var obj = git("cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep '\\(tag\\|commit\\)$' | cut -f1 -d' '", true)
|
||||||
var dict = {}
|
var dict = {}
|
||||||
for o in obj:
|
for o in obj:
|
||||||
dict[o] = ""
|
dict[o] = ""
|
||||||
|
|
|
@ -10,3 +10,5 @@
|
||||||
decorate = true
|
decorate = true
|
||||||
[advice]
|
[advice]
|
||||||
detachedHead = false
|
detachedHead = false
|
||||||
|
[receive]
|
||||||
|
denyCurrentBranch = ignore
|
||||||
|
|
Loading…
Reference in a new issue