benthayer / git-gud

Wanna git gud? Then get git-gud, and git gud at git!
MIT License
414 stars 43 forks source link

Broken everything during level 4.1 #342

Closed valerionew closed 3 years ago

valerionew commented 3 years ago

Hey! Just discovered this but unfortunately i broke everything during level 4.1. Assignment was to rebase bugfix onto master, so what i do is:

git rebase -i master

Then do the rebase as follows:

d db34422 Commit 2
d 863b61a Commit 3
pick 8d5b202 Commit 4

After that i go testing and i get:

valerio@DESKTOP-65ETA1A .../Documents/git-gud (bugFix) $ git gud test
Traceback (most recent call last):
  File "/home/valerio/.local/bin/git-gud", line 8, in <module>
    sys.exit(main())
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 554, in main
    GitGud().parse()
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 548, in parse
    args.func(self, args)
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 24, in <lambda>
    parser.set_defaults(func=lambda gg, args: handler(gg, args))
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 200, in handle_test
    get_operator().get_level().test()
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/level_builder.py", line 71, in test
    passed = self._test()
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/level_builder.py", line 211, in _test
    name_from_map(level_tree, diff_map)
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/parsing.py", line 221, in name_from_map
    mapping[level_tree['tags'][tag]['target']]
KeyError: '2' 

Now i'm stuck on this, no reset works, no load works. I have to delete the two leftover tags to be able to move formward in the game, with git tag -d debug printf. After that it tests unsuccessfull and i can reset it

sahansk2 commented 3 years ago

I was able to replicate the above KeyError, but I wasn't able to replicate the inability to reset (git gud reset) or reload the level (git gud load 4-1). What OS are you on, and what Python version are you on (python3 --version) or (python --version)?

Right now, I'm on Python version 3.8.5 on Ubuntu 20.04.

valerionew commented 3 years ago

I tried again and i confirm that i'm unable to reset and to load a new level.

I'm in WSL (ubuntu 20.04):

$ uname -a
Linux DESKTOP-65ETA1A 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

With python 3.8.5

sahansk2 commented 3 years ago

Could you paste the error/stack trace that comes up when you try to reset or load a new level, like how you did for the KeyError?

valerionew commented 3 years ago

Sure! It looks the same to me:

$ git gud reset
Traceback (most recent call last):
  File "/home/valerio/.local/bin/git-gud", line 8, in <module>
    sys.exit(main())
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 554, in main
    GitGud().parse()
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 548, in parse
    args.func(self, args)
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 24, in <lambda>
    parser.set_defaults(func=lambda gg, args: handler(gg, args))
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 186, in handle_reset
    file_operator.update_level_completion()
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/operations.py", line 446, in update_level_completion
    if level._test():
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/level_builder.py", line 211, in _test
    name_from_map(level_tree, diff_map)
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/parsing.py", line 221, in name_from_map
    mapping[level_tree['tags'][tag]['target']]
KeyError: '2'
$ git gud load 4-1
Traceback (most recent call last):
  File "/home/valerio/.local/bin/git-gud", line 8, in <module>
    sys.exit(main())
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 554, in main
    GitGud().parse()
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 548, in parse
    args.func(self, args)
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 24, in <lambda>
    parser.set_defaults(func=lambda gg, args: handler(gg, args))
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/__main__.py", line 394, in handle_load
    get_operator().update_level_completion()
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/operations.py", line 446, in update_level_completion
    if level._test():
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/level_builder.py", line 211, in _test
    name_from_map(level_tree, diff_map)
  File "/home/valerio/.local/lib/python3.8/site-packages/gitgud/util/parsing.py", line 221, in name_from_map
    mapping[level_tree['tags'][tag]['target']]
KeyError: '2'
sahansk2 commented 3 years ago

Thanks - it looks like I was accidentally on a much older Git Gud development version, which is why I couldn't replicate it. After installing Git Gud v0.4.1 from pip, I was able to replicate the issue. My bad!

To add to your issue, it seems like this KeyError persists even after following through to complete the level objective. For example, following either of these sequences of steps after what you did should have completed the level:

or

But neither of these work.

Not being able to reset or load any levels is pretty problematic as well.

While these bugs are getting fixed, @valerionew, you could check out the "official" solution for this level by running git gud solution. That solution still works.

sahansk2 commented 3 years ago

@benthayer , what are your thoughts?

valerionew commented 3 years ago

Yeah before opening the issue i managed to solve the level taking the other path and finish the game. It was a fun trip, thank you guys!

benthayer commented 3 years ago

I've been thinking about how it might be useful to add tests for incorrect solutions. Right now we just test the correct solution. For incorrect solutions we might check to make sure that it doesn't crash or pass the tests.

But otherwise, it makes sense that git gud reset (and some others I think) should crash because of the update level completion stuff. Obviously this is also a bug that needs to be fixed, so we should fix it. @valerionew thanks for posting about this. I'll check the code and see what I can do about it

benthayer commented 3 years ago

@valerionew @sahansk2 Turns out the fix is a one-liner!