Gazler / githug

Git your game on!
MIT License
6.86k stars 1.03k forks source link

Updated solution to check commits in correct order #163

Closed KyleDSwarner closed 10 years ago

KyleDSwarner commented 10 years ago

The solution for this level checked for the commits in the wrong order as they were added in the setup, making the level impossible without a rebase to fix the issue.

Gazler commented 10 years ago

Here is my trace for that level:

gazler@gazler-desktop-pc:~/git_hug$ git --version
git version 1.8.1.2
gazler@gazler-desktop-pc:~/git_hug$ githug reset revert
********************************************************************************
*                                    Githug                                    *
********************************************************************************
resetting level

Name: revert
Level: 50
Difficulty: ****

You have committed several times but want to undo the middle commit.
All commits have been pushed, so you can't change existing history.

gazler@gazler-desktop-pc:~/git_hug$ git log
6695434 Second commit (0 seconds ago, Gary Rennie)
f832d95 Bad commit (0 seconds ago, Gary Rennie)
4f1937f First commit (0 seconds ago, Gary Rennie)
gazler@gazler-desktop-pc:~/git_hug$ git revert f832d95
[master 2d15ab6] Revert "Bad commit"
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 file3
gazler@gazler-desktop-pc:~/git_hug$ git log
2d15ab6 Revert "Bad commit" (4 seconds ago, Gary Rennie)
6695434 Second commit (13 seconds ago, Gary Rennie)
f832d95 Bad commit (13 seconds ago, Gary Rennie)
4f1937f First commit (13 seconds ago, Gary Rennie)
gazler@gazler-desktop-pc:~/git_hug$ githug
********************************************************************************
*                                    Githug                                    *
********************************************************************************
Congratulations, you have solved the level!

Please could you confirm your version of git and try with my solution?

KyleDSwarner commented 10 years ago

Yep, here's mine. Same commands don't work. This is a Windows box, which could be the fault. Checking commits in a different order somehow?

KDS@Aurora /i/Education/git_hug (master)
$ git --version
git version 1.9.0.msysgit.0

KDS@Aurora /i/Education/git_hug (master)
$ githug reset revert
********************************************************************************

*                                    Githug                                    *

********************************************************************************

resetting level

Name: revert
Level: 50
Difficulty: ****

You have committed several times but want to undo the middle commit.
All commits have been pushed, so you can't change existing history.

KDS@Aurora /i/Education/git_hug (master)
$ git log
commit 4b8d0ecd1492b879a5001f237aa37196709e6eb0
Author: Swarner, Kyle <kyle.swarner@fmr.com>
Date:   Wed May 28 16:46:59 2014 -0400

    Second commit

commit 6c423571e2bcfaf119376cdaa69be681368ad982
Author: Swarner, Kyle <kyle.swarner@fmr.com>
Date:   Wed May 28 16:46:56 2014 -0400

    Bad commit

commit 6439b1251854725fc985c40dff3888af85944df7
Author: Swarner, Kyle <kyle.swarner@fmr.com>
Date:   Wed May 28 16:46:55 2014 -0400

    First commit

KDS@Aurora /i/Education/git_hug (master)
$ git revert 6c42357
[master 404b738] Revert "Bad commit"
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 file3

KDS@Aurora /i/Education/git_hug (master)

$ git log
commit 404b7385c9838963a02fcf53b189d2dabd034150
Author: Swarner, Kyle <kyle.swarner@fmr.com>
Date:   Wed May 28 16:47:40 2014 -0400

    Revert "Bad commit"

    This reverts commit 6c423571e2bcfaf119376cdaa69be681368ad982.

commit 4b8d0ecd1492b879a5001f237aa37196709e6eb0
Author: Swarner, Kyle <kyle.swarner@fmr.com>
Date:   Wed May 28 16:46:59 2014 -0400

    Second commit

commit 6c423571e2bcfaf119376cdaa69be681368ad982
Author: Swarner, Kyle <kyle.swarner@fmr.com>
Date:   Wed May 28 16:46:56 2014 -0400

    Bad commit

commit 6439b1251854725fc985c40dff3888af85944df7
Author: Swarner, Kyle <kyle.swarner@fmr.com>
Date:   Wed May 28 16:46:55 2014 -0400

    First commit

$ githug
********************************************************************************

*                                    Githug                                    *

********************************************************************************

Sorry, this solution is not quite right!

Name: revert
Level: 50
Difficulty: ****

You have committed several times but want to undo the middle commit.
All commits have been pushed, so you can't change existing history.
Gazler commented 10 years ago

@KyleDSwarner Hopefully it is a git 1.9 issue - I'll knock up a test machine with 1.9 on it and give it a go.

Gazler commented 10 years ago

@KyleDSwarner I have just tested with git 1.9.1 and the level passes fine (it was inside an Ubuntu 14.04 docker image.) Unfortunately testing on windows is a bit more difficult for me as I don't have access to a Windows machine at the moment.

Could you please run the following for me inside your git_hug directory:

githug reset revert
git revert HEAD^
git log --oneline
ruby -e "require 'githug'; repo = Grit::Repo.new('.'); p repo.commits"

You're output should look something like:

gazler@gazler-desktop-pc:~/git_hug$ githug reset revert
********************************************************************************
*                                    Githug                                    *
********************************************************************************
resetting level

Name: revert
Level: 50
Difficulty: ****

You have committed several times but want to undo the middle commit.
All commits have been pushed, so you can't change existing history.

gazler@gazler-desktop-pc:~/git_hug$ git revert HEAD^
[master 29700dd] Revert "Bad commit"
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 file3
gazler@gazler-desktop-pc:~/git_hug$ git log --oneline
29700dd Revert "Bad commit"
55bda55 Second commit
a415045 Bad commit
a7388f1 First commit
gazler@gazler-desktop-pc:~/git_hug$ ruby -e "require 'githug'; repo = Grit::Repo.new('.'); p repo.commits"
[#<Grit::Commit "29700dd24015c8271075147a4da5c230cdaf9fee">, #<Grit::Commit "a415045f5324dff7155a62c5454bada36dd92090">, #<Grit::Commit "55bda5554cef17e01320e6dd5506e8f661f483f3">, #<Grit::Commit "a7388f1a2e941e4237172fbab9d6d1b72d5a1a33">]
KyleDSwarner commented 10 years ago

@Gazler Sure, attached is the output.

Curiously, the solution worked with these commands, and retrying the original solution also works now. It's very possible my machine was being difficult the first time I tried this...

KDS@Aurora /c/users/KSD/desktop/git_hug (master)
$ githug reset revert
********************************************************************************
*                                    Githug                                    *
********************************************************************************
resetting level

Name: revert
Level: 50
Difficulty: ****

You have committed several times but want to undo the middle commit.
All commits have been pushed, so you can't change existing history.

KDS@Aurora /c/users/KSD/desktop/git_hug (master)
$ git revert HEAD^
[master 926ea35] Revert "Bad commit"
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 file3

KDS@Aurora /c/users/KSD/desktop/git_hug (master)
$ git log --oneline
926ea35 Revert "Bad commit"
01c055e Second commit
6135bae Bad commit
b3d4ba3 First commit

KDS@Aurora /c/users/KSD/desktop/git_hug (master)
$ ruby -e "require 'githug'; repo = Grit::Repo.new('.'); p repo.commits"
[#<Grit::Commit "926ea35122d739c7f0237c9843a47280c729b0d4">, #<Grit::Commit "613
5bae4d28042c47938cc2736363adb397e7c57">, #<Grit::Commit "01c055eac79502c19b9a646
c6ab017c411ff53d7">, #<Grit::Commit "b3d4ba3336874d199dd939a8d8facfb0198c36fa">]
Gazler commented 10 years ago

@KyleDSwarner glad to hear it works - I don't really have any ideas on what the issue could have been. If you're convinced that it is no longer an image and some bizarre machine issue then I am happy for you to close off this issue.

If you happen across it again then the output of those steps would be very helpful.

KyleDSwarner commented 10 years ago

@Gazler Sure, I'll let you know if I run across it again, but you can close this for now. Sorry for the trouble.

Gazler commented 10 years ago

@KyleDSwarner No trouble at all.