Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Introduce reflog #388

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 3 commits into from
Apr 10, 2013
Merged

Introduce reflog #388

merged 3 commits into from
Apr 10, 2013

Conversation

Saaman
Copy link
Contributor

@Saaman Saaman commented Apr 8, 2013

This PR is originated by issue #371.

I first introduced the ability to read the reflog :

ReflogCollection reflog = repo.Refs.Log(string canonicalReferenceName);
ReflogCollection reflog = repo.Refs.Log(Reference reference);

A ReflogCollectionis a IEnumerable<ReflogEntry>, where ReflogEntrycontains details about a single entry.

Then I corrected the issue by calling ReflogCollection.Append() from the Repository.Commit() method.
I implemented correct message formatting for standard commits and ammended commits. I'm not sure if there is another case to cover.

  • Travis OK
  • First review
  • First amend
  • Merged!

@nulltoken
Copy link
Member

@haacked How do you feel about this?

@nulltoken
Copy link
Member

@Saaman Travis chokes because of a tiny case related issue.

@haacked
Copy link
Contributor

haacked commented Apr 8, 2013

@nulltoken excited to see this! Having it automatically created on commit sounds good to me.

What about other cases when reflog entries are created such as checking out branches and merging two branches?

@nulltoken
Copy link
Member

What about other cases when reflog entries are created such as checking out branches and merging two branches?

@haacked Merging seems a bit far away. However, checking out sounds achievable.

Maybe could you create a separate feature request with the use cases you'd like to see implemented?

@haacked
Copy link
Contributor

haacked commented Apr 8, 2013

Sure.

@Saaman
Copy link
Contributor Author

Saaman commented Apr 8, 2013

@nulltoken Sorry, I missed a couple of things in my class definitions. Travis should not complain anymore. 🙏


// Initial commit assertions
Assert.Equal("[email protected]", reflog.Last().Commiter.Email);
Assert.Contains("clone: from c:/GitHub/libgit2sharp/Resources/testrepo.git", reflog.Last().Message);
Copy link
Member

Choose a reason for hiding this comment

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

Would StartWith() work as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used Contains() because there was a trailing "\r" in the clone message... Maybe a minor bug from libgit? This does not happen on commit related reflog entries.
Anyway, I can make it work with Assert.Equal() adding the trailing "\r" in my expectation.
Although, StartWith() does not belong to XUnit built-in assertions methods!

Saaman added 3 commits April 10, 2013 18:24
returns the reflog of the reference given as parameter
Fix libgit2#371

Insert entry on HEAD and target direct reference on commit
Tag as initial the first commit
@Saaman
Copy link
Contributor Author

Saaman commented Apr 10, 2013

Here is a first amend on the PR.
Among some rewriting, I also :

  • fixed a bug on ReferenceCollection.UpdateTarget(). It was not possible to have "HEAD" target a SymbolicReference. It worked with signature using references names, but not with the one using actual Reference objects.
  • When "HEAD" targets a SymbolicReference the "HEAD" reflog and DirectReference reflog must be updated (this is the behavior of git.exe).
  • Add (initial) in the reflog entry message when the Reference is unborn.

@nulltoken nulltoken merged commit 90c9b20 into libgit2:vNext Apr 10, 2013
@nulltoken
Copy link
Member

@Saaman Travis ❤️ you. And so am I!

Merged.

@Saaman Saaman deleted the topic/reflog branch April 15, 2013 12:10
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.

4 participants