8000 Track commits in .git/gud/commits.json by parkmichael777 · Pull Request #123 · benthayer/git-gud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Dismiss alert

Track commits in .git/gud/commits.json #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Feb 7, 2020

Conversation

parkmichael777
Copy link
Contributor
@parkmichael777 parkmichael777 commented Dec 19, 2019

fixes #40

@parkmichael777
Copy link
Contributor Author

#40

Here's what happens as of now:

  1. When you load a skill, load a level, or reset a level, the .git/gud/commits.json file is overwritten with a fresh file. This file is populated with whatever commits the level is initialized with.
  2. Whenever a user uses "git gud commit" the commits.json file will add a dictionary entry.

commit_name => "C#"
commit_hash => C#'s commit hash.

I haven't built any functions to read the JSON file, but that should be easy enough.

Copy link
Owner
@benthayer benthayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all pretty good and works perfectly off the bat!

Still, a few code changes

@benthayer
Copy link
Owner

We don't need the reading just yet. It's not clear what we're going to need this for, so we can hold off on doing that until we start running into issues and need this.

We'll probably need this when working with rebases and merges and trying to figure out if the user has solved a given level

- create_tree uses commit_obj variable
- System now uses Operator for file navigation
- Renamed track_commits to track_commit
Added to handle_init and handle_reset
@parkmichael777
Copy link
Contributor Author

I need to reset the tracking json whenever there is a new level; I do this for load, reset, and init. Are there any more that I don't know about or am forgetting?

Copy link
Owner
@benthayer benthayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tentative approval

Copy link
Owner
@benthayer benthayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of init_tracking_json every time, put init_tracking_json in the load_level function.

I think it would be more clear if we rename init_tracking_json to clear_tracked_commits

One more thing. I've uploaded a change to the master branch that will cause a merge conflict in handle_init but does part of your work for you. My changes reduce redundant code.

You also skipped load_level in handle_progress, but that should be fixed when you add init_tracking_json to load_level

As for testing, write a function that loads a level, reads the json and then just makes sure the dictionary is the correct length. The only level that doesn't have anything fancy in it is the first one, which is just a bunch of commits, so use that one. We won't know the hashes, so this is a good simple test. If you have other ideas, feel free to bring them up.

That's it. Mostly reorganization - the needed functionality is already there.

- Renamed init_tracking_json to clear_tracked_commits
- Moved init_tracking_json to load_level, and removed code resulting obsolete code.
- Moved track_commit from handle_commit to add_and_commit
@parkmichael777
Copy link
Contributor Author

All requested changes have been made.

In regards to the "test," are you talking about the CircleCI tests? Or a git gud test for the user?

@benthayer benthayer merged commit e788942 into benthayer:master Feb 7, 2020
@benthayer benthayer mentioned this pull request Feb 9, 2020
@parkmichael777 parkmichael777 deleted the track_commits branch August 24, 2020 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
434E
Development

Successfully merging this pull request may close these issues.

Keep track of commit hashes using a .json file
2 participants
0