Skip to content
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

Show all commits in order #62

Merged
merged 1 commit into from
Jun 10, 2020
Merged

Conversation

jelaniwoods
Copy link
Contributor

@jelaniwoods jelaniwoods commented May 3, 2020

Resolves #55

Add this to your Gemfile and bundle

gem "web_git", github: "firstdraft/web_git", branch: "jw-show-all-commits-in-graph"

Run

rails g web_git:install

Visit /git/log to see the graph data in JSON.

Visit /git and scroll to the black box to see all the commits.

This branch adds the following:
- Shows each commit made on every branch (similar to git log --graph)

  • Shows all the commits in each Branch

Approach:

  • if current branch has untracked changes, temporarily stash changes
  • Find commit log for each branch (Array of commit Hashes)
  • Create an Array of all unique commits
    • Store other useful info, date, message, author, formatted date, HEAD
  • Pop stash if branch had changes
  • View template loops through each branch, sorted by date of HEAD, and formats the commits

screencapture-localhost-3000-git-1591655782863 (1)

@jelaniwoods jelaniwoods changed the title Get all branches and the logs for those branches. Show all commits in order May 18, 2020
@jelaniwoods jelaniwoods force-pushed the jw-show-all-commits-in-graph branch from b453cdc to a90c640 Compare May 25, 2020 19:37
@raghubetina
Copy link
Contributor

@jelaniwoods Oddly I am getting "no route matches" for both /git and /git/log when I add the gem to a project. E.g., I added it to ildashboard here:

https://github.com/raghubetina/ildashboard/pull/13

When I spin up a server and visit /git, I get a "no route matches".

@jelaniwoods
Copy link
Contributor Author

jelaniwoods commented May 29, 2020

@raghubetina I forgot to mention the rails g web_git:install for modify the config.ru! I assume that was the issue— the invitation to collaborate on iidashboard expired so I can't view what you tried.

@raghubetina
Copy link
Contributor

raghubetina commented May 29, 2020

@jelaniwoods That was it. Excellent work so far. It looks to me like it's drawing all of the commits from across all branches in a one-dimensional history, though:

Screen Shot 2020-05-29 at 12 45 50 PM

Although /git/log does have the data in a multi-dimensional structure:

Screen Shot 2020-05-29 at 12 46 13 PM

--graph does something like this:

Screen Shot 2020-05-29 at 12 48 06 PM

@raghubetina
Copy link
Contributor

raghubetina commented May 29, 2020

@jelaniwoods What do you think about using a library to draw the graph? I found this after a quick search: https://gitgraphjs.com/

@raghubetina
Copy link
Contributor

@jelaniwoods As an intermediate solution before we go down a full-on graphing library road, how about drawing each branch's commits in a separate box?

I think intermingling them in one history is confusing.

@jelaniwoods
Copy link
Contributor Author

jelaniwoods commented May 29, 2020

@raghubetina thanks for the review!

It looks to me like it's drawing all of the commits from across all branches in a one-dimensional history

That was kind of my intention—

  • Find commit log for each branch (Array of commit Hashes)
  • Create an Array of all unique commits
    ...
  • View template loops through the combined commit list and formats the commits

It looks like I misunderstood the "Merge logs at those points" from your previous comment. I also leaned more into git log --all than git log --graph apparently.

What do you think about using a library to draw the graph?

I assumed that would be the next step after this one— done in a separate PR.

how about drawing each branch's commits in a separate box

Do you mean only the unique commits for each branch? Is there a specific order the branches should be listed?

@raghubetina
Copy link
Contributor

raghubetina commented May 29, 2020

@jelaniwoods Yes, I should have been more clear earlier. Sorry about that.

Do you mean only the unique commits for each branch? Is there a specific order the branches should be listed?

Not necessarily the unique commits; it could just be all the commits (the log) for each branch.

How about ordering branches by time of most recent commit (descending), and then drawing its log box?

So basically you already have the array of data that you need at /git/log, it just needs a sort using the date of head?

@jelaniwoods
Copy link
Contributor Author

Okay, I will update with those changes.

@jelaniwoods
Copy link
Contributor Author

@raghubetina I've made the changes you suggested and am ready for more review!

@raghubetina
Copy link
Contributor

@jelaniwoods When I try to review on the same app after a bundle update, I seem to be getting the slowness that students reported. I don't know if it has to do with the changes made since then or not. Same warning message, although perhaps that is unrelated too:

/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block
/Users/raghubetina/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/status.rb:175: warning: conflicting chdir during another chdir block

@raghubetina
Copy link
Contributor

@jelaniwoods The page is ultimately not loading for me, I get bounced with:

Screen Shot 2020-06-09 at 9 20 43 AM

@jelaniwoods jelaniwoods force-pushed the jw-show-all-commits-in-graph branch 3 times, most recently from d61841a to 14456a8 Compare June 9, 2020 15:54
@jelaniwoods jelaniwoods force-pushed the jw-show-all-commits-in-graph branch from 14456a8 to a67dd43 Compare June 10, 2020 20:50
@jelaniwoods jelaniwoods merged commit a67dd43 into spring2020 Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log should list ALL commits from any branch similar to git log --all
2 participants