mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Properly support symrefs in refs/
This commit is contained in:
parent
8a6f957c61
commit
cb2bb767db
4 changed files with 41 additions and 23 deletions
7
main.gd
7
main.gd
|
@ -85,6 +85,9 @@ func load_level(id):
|
||||||
var dir = Directory.new()
|
var dir = Directory.new()
|
||||||
dir.copy(win_script, win_script_target)
|
dir.copy(win_script, win_script_target)
|
||||||
|
|
||||||
|
func reload_level():
|
||||||
|
load_level(current_level)
|
||||||
|
|
||||||
func load_next_level():
|
func load_next_level():
|
||||||
current_level = (current_level + 1) % list_levels().size()
|
current_level = (current_level + 1) % list_levels().size()
|
||||||
load_level(current_level)
|
load_level(current_level)
|
||||||
|
@ -93,8 +96,8 @@ func construct_repo(script, path):
|
||||||
# Becase in an exported game, all assets are in a .pck file, we need to put
|
# Becase in an exported game, all assets are in a .pck file, we need to put
|
||||||
# the script somewhere in the filesystem.
|
# the script somewhere in the filesystem.
|
||||||
var content = ""
|
var content = ""
|
||||||
if ResourceLoader.exists(script):
|
#if ResourceLoader.exists(script):
|
||||||
content = game.read_file(script)
|
content = game.read_file(script)
|
||||||
var script_path_outside = game.tmp_prefix+"/git-hydra-script"
|
var script_path_outside = game.tmp_prefix+"/git-hydra-script"
|
||||||
var script_path = "/tmp/git-hydra-script"
|
var script_path = "/tmp/git-hydra-script"
|
||||||
game.write_file(script_path_outside, content)
|
game.write_file(script_path_outside, content)
|
||||||
|
|
21
main.tscn
21
main.tscn
|
@ -118,11 +118,10 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="NextLevelButton" type="Button" parent="."]
|
[node name="NextLevelButton" type="Button" parent="."]
|
||||||
visible = false
|
margin_left = 1688.03
|
||||||
margin_left = 1403.0
|
margin_top = 16.2615
|
||||||
margin_top = 16.0
|
margin_right = 1906.03
|
||||||
margin_right = 1621.0
|
margin_bottom = 47.2615
|
||||||
margin_bottom = 47.0
|
|
||||||
custom_styles/hover = SubResource( 1 )
|
custom_styles/hover = SubResource( 1 )
|
||||||
custom_styles/normal = ExtResource( 4 )
|
custom_styles/normal = ExtResource( 4 )
|
||||||
custom_fonts/font = ExtResource( 5 )
|
custom_fonts/font = ExtResource( 5 )
|
||||||
|
@ -130,5 +129,17 @@ text = "Next Level"
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="ReloadButton" type="Button" parent="."]
|
||||||
|
margin_left = 1400.72
|
||||||
|
margin_top = 16.2615
|
||||||
|
margin_right = 1545.72
|
||||||
|
margin_bottom = 47.2615
|
||||||
|
custom_fonts/font = ExtResource( 5 )
|
||||||
|
text = "Reload"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
[connection signal="pressed" from="TextEditor/SaveButton" to="." method="save_message"]
|
[connection signal="pressed" from="TextEditor/SaveButton" to="." method="save_message"]
|
||||||
[connection signal="pressed" from="NextLevelButton" to="." method="load_next_level"]
|
[connection signal="pressed" from="NextLevelButton" to="." method="load_next_level"]
|
||||||
|
[connection signal="pressed" from="ReloadButton" to="." method="reload_level"]
|
||||||
|
|
6
node.gd
6
node.gd
|
@ -39,9 +39,8 @@ func type_set(new_type):
|
||||||
type = new_type
|
type = new_type
|
||||||
if type != "ref":
|
if type != "ref":
|
||||||
$ID.text = $ID.text.substr(0,8)
|
$ID.text = $ID.text.substr(0,8)
|
||||||
elif type == "ref":
|
#elif type == "ref":
|
||||||
var parts = $ID.text.split("/")
|
#$ID.text = $ID.text.replace("refs/", "")
|
||||||
$ID.text = parts[parts.size()-1]
|
|
||||||
match new_type:
|
match new_type:
|
||||||
"blob":
|
"blob":
|
||||||
$Rect.color = Color("#333333")
|
$Rect.color = Color("#333333")
|
||||||
|
@ -51,7 +50,6 @@ func type_set(new_type):
|
||||||
$Rect.color = Color.orange
|
$Rect.color = Color.orange
|
||||||
"tag":
|
"tag":
|
||||||
$Rect.color = Color.blue
|
$Rect.color = Color.blue
|
||||||
id_always_visible = true
|
|
||||||
"ref":
|
"ref":
|
||||||
$Rect.color = Color("#6680ff")
|
$Rect.color = Color("#6680ff")
|
||||||
id_always_visible = true
|
id_always_visible = true
|
||||||
|
|
|
@ -78,6 +78,9 @@ func update_objects():
|
||||||
for p in commit_parents(o):
|
for p in commit_parents(o):
|
||||||
c[p] = ""
|
c[p] = ""
|
||||||
n.children = c
|
n.children = c
|
||||||
|
"tag":
|
||||||
|
print("tag")
|
||||||
|
n.children = tag_target(o)
|
||||||
add_child(n)
|
add_child(n)
|
||||||
objects[o] = n
|
objects[o] = n
|
||||||
|
|
||||||
|
@ -93,7 +96,7 @@ func update_refs():
|
||||||
objects[r] = n
|
objects[r] = n
|
||||||
add_child(n)
|
add_child(n)
|
||||||
var n = objects[r]
|
var n = objects[r]
|
||||||
n.children = {ref_id(r): ""}
|
n.children = {ref_target(r): ""}
|
||||||
|
|
||||||
func apply_forces():
|
func apply_forces():
|
||||||
for o in objects.values():
|
for o in objects.values():
|
||||||
|
@ -134,10 +137,10 @@ func update_head():
|
||||||
objects["HEAD"] = n
|
objects["HEAD"] = n
|
||||||
add_child(n)
|
add_child(n)
|
||||||
var n = objects["HEAD"]
|
var n = objects["HEAD"]
|
||||||
n.children = {symref_target("HEAD"): ""}
|
n.children = {ref_target("HEAD"): ""}
|
||||||
if not objects.has(symref_target("HEAD")):
|
if not objects.has(ref_target("HEAD")):
|
||||||
var n2 = node.instance()
|
var n2 = node.instance()
|
||||||
var r = symref_target("HEAD")
|
var r = ref_target("HEAD")
|
||||||
n2.id = r
|
n2.id = r
|
||||||
n2.type = "ref"
|
n2.type = "ref"
|
||||||
n2.content = ""
|
n2.content = ""
|
||||||
|
@ -182,6 +185,10 @@ func commit_parents(id):
|
||||||
parents.push_back(ccc[1])
|
parents.push_back(ccc[1])
|
||||||
return parents
|
return parents
|
||||||
|
|
||||||
|
func tag_target(id):
|
||||||
|
var c = git("rev-parse %s^{}" % id)
|
||||||
|
return {c: ""}
|
||||||
|
|
||||||
func all_refs():
|
func all_refs():
|
||||||
var refs = []
|
var refs = []
|
||||||
# If there are no refs, show-ref will have exit code 1. We don't care.
|
# If there are no refs, show-ref will have exit code 1. We don't care.
|
||||||
|
@ -192,11 +199,10 @@ func all_refs():
|
||||||
refs.push_back(name)
|
refs.push_back(name)
|
||||||
return refs
|
return refs
|
||||||
|
|
||||||
func ref_id(ref):
|
func ref_target(ref):
|
||||||
return git("show-ref "+ref).split(" ")[0]
|
# Test whether this is a symbolic ref.
|
||||||
|
var ret = git("symbolic-ref -q "+ref+" || true")
|
||||||
func symref_target(symref):
|
# If it's not, it's probably a regular ref.
|
||||||
var ret = git("symbolic-ref -q "+symref)
|
if ret == "":
|
||||||
if ret != "":
|
ret = git("show-ref --head "+ref).split(" ")[0]
|
||||||
return ret
|
return ret
|
||||||
return git("show-ref --head "+symref).split(" ")[0]
|
|
||||||
|
|
Loading…
Reference in a new issue