mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Win Script test for blob level
This commit is contained in:
parent
75679c8bb1
commit
39d952528f
3 changed files with 18 additions and 2 deletions
7
levels/01-blob/win
Normal file
7
levels/01-blob/win
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
BLOB_COUNT=$(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep blob | wc -l)
|
||||||
|
|
||||||
|
if [ "$BLOB_COUNT" -gt 2 ]; then
|
||||||
|
echo yes
|
||||||
|
else
|
||||||
|
echo no
|
||||||
|
fi
|
7
main.gd
7
main.gd
|
@ -76,6 +76,11 @@ func load_level(id):
|
||||||
goal_repository.path = goal_repository_path
|
goal_repository.path = goal_repository_path
|
||||||
active_repository.path = active_repository_path
|
active_repository.path = active_repository_path
|
||||||
|
|
||||||
|
var win_script = level_prefix+level+"/win"
|
||||||
|
var win_script_target = game.tmp_prefix+"/win"
|
||||||
|
var dir = Directory.new()
|
||||||
|
dir.copy(win_script, win_script_target)
|
||||||
|
|
||||||
func construct_repo(script, path):
|
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.
|
||||||
|
@ -87,7 +92,7 @@ func construct_repo(script, path):
|
||||||
game.global_shell.run("mkdir " + path)
|
game.global_shell.run("mkdir " + path)
|
||||||
game.global_shell.cd(path)
|
game.global_shell.cd(path)
|
||||||
game.global_shell.run("git init")
|
game.global_shell.run("git init")
|
||||||
var o = game.global_shell.run("source "+script_path)
|
var o = game.global_shell.run("sh "+script_path)
|
||||||
|
|
||||||
if game.debug:
|
if game.debug:
|
||||||
print(o)
|
print(o)
|
||||||
|
|
|
@ -41,10 +41,14 @@ func send_command_async(command):
|
||||||
|
|
||||||
func run_command_in_a_thread(command):
|
func run_command_in_a_thread(command):
|
||||||
var o = repo.shell.run(command)
|
var o = repo.shell.run(command)
|
||||||
|
check_win_condition()
|
||||||
|
|
||||||
input.text = ""
|
input.text = ""
|
||||||
output.text = output.text + "$ " + command + "\n" + o
|
output.text = output.text + "$ " + command + "\n" + o
|
||||||
repo.update_everything() # FIXME
|
repo.update_everything()
|
||||||
|
|
||||||
func receive_output(text):
|
func receive_output(text):
|
||||||
output.text += text
|
output.text += text
|
||||||
|
|
||||||
|
func check_win_condition():
|
||||||
|
print( repo.shell.run("bash /tmp/win") )
|
||||||
|
|
Loading…
Reference in a new issue