mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-02 10:52:00 +03:00
Remove nodes that are no longer present in the repository
This commit is contained in:
parent
e7914f281d
commit
47532c9033
@ -22,6 +22,7 @@ func update_everything():
|
|||||||
update_refs()
|
update_refs()
|
||||||
update_index()
|
update_index()
|
||||||
update_objects()
|
update_objects()
|
||||||
|
remove_gone_stuff()
|
||||||
|
|
||||||
func set_path(new_path):
|
func set_path(new_path):
|
||||||
path = new_path
|
path = new_path
|
||||||
@ -45,7 +46,10 @@ func random_position():
|
|||||||
return Vector2(rand_range(0, rect_size.x), rand_range(0, rect_size.y))
|
return Vector2(rand_range(0, rect_size.x), rand_range(0, rect_size.y))
|
||||||
|
|
||||||
func update_objects():
|
func update_objects():
|
||||||
for o in all_objects():
|
var all = all_objects()
|
||||||
|
|
||||||
|
# Create new objects, if necessary.
|
||||||
|
for o in all:
|
||||||
if objects.has(o):
|
if objects.has(o):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -152,7 +156,11 @@ func update_head():
|
|||||||
n.children = {ref_target("HEAD"): ""}
|
n.children = {ref_target("HEAD"): ""}
|
||||||
|
|
||||||
func all_objects():
|
func all_objects():
|
||||||
return git("cat-file --batch-check='%(objectname)' --batch-all-objects", true)
|
var objects = git("cat-file --batch-check='%(objectname)' --batch-all-objects", true)
|
||||||
|
var dict = {}
|
||||||
|
for o in objects:
|
||||||
|
dict[o] = ""
|
||||||
|
return dict
|
||||||
|
|
||||||
func object_type(id):
|
func object_type(id):
|
||||||
return git("cat-file -t "+id)
|
return git("cat-file -t "+id)
|
||||||
@ -192,13 +200,13 @@ func tag_target(id):
|
|||||||
return {c: ""}
|
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.
|
||||||
for line in git("show-ref || true", true):
|
for line in git("show-ref || true", true):
|
||||||
line = line.split(" ")
|
line = line.split(" ")
|
||||||
var _id = line[0]
|
var _id = line[0]
|
||||||
var name = line[1]
|
var name = line[1]
|
||||||
refs.push_back(name)
|
refs[name] = ""
|
||||||
return refs
|
return refs
|
||||||
|
|
||||||
func ref_target(ref):
|
func ref_target(ref):
|
||||||
@ -222,3 +230,17 @@ func simplify_view(pressed):
|
|||||||
obj.visible = not pressed
|
obj.visible = not pressed
|
||||||
|
|
||||||
update_objects()
|
update_objects()
|
||||||
|
|
||||||
|
func remove_gone_stuff():
|
||||||
|
# FIXME: Cache the result of all_objects.
|
||||||
|
var all = {}
|
||||||
|
for o in all_objects():
|
||||||
|
all[o] = ""
|
||||||
|
for o in all_refs():
|
||||||
|
all[o] = ""
|
||||||
|
all["HEAD"] = ""
|
||||||
|
# Delete objects, if they disappeared.
|
||||||
|
for o in objects:
|
||||||
|
if not all.has(o):
|
||||||
|
objects[o].queue_free()
|
||||||
|
objects.erase(o)
|
||||||
|
Loading…
Reference in New Issue
Block a user