Skip to content

Update commit to return an object, matching the documentation #451

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

Closed

Conversation

jamesiarmes
Copy link

Signed-off-by: James Armes jamesiarmes@gmail.com

Your checklist for this pull request

🚨Please review the guidelines for contributing to this repository.

  • Ensure all commits include DCO sign-off.
  • Ensure that your contributions pass unit testing.
  • Ensure that your contributions contain documentation if applicable.

Description

According to the documentation, both the commit and commit_all methods should return an object, but instead they return the output from running git commit as a string. This pull requests update these methods to return an object, matching the documentation.

Signed-off-by: James Armes <jamesiarmes@gmail.com>
@jcouball jcouball changed the title Update commit to return an object, matching the documntation. Update commit to return an object, matching the documentation Feb 12, 2020
@jcouball
Copy link
Member

hmm, commit and commit_all do return an Object. It just so happens that the object is a String.

The documentation could definitely use some improvement. I have gotten that started in #448.

I am hesitant to change an interface that has been in place for so long with out a major version bump.

Thoughts?

@jamesiarmes
Copy link
Author

To be clear, the documentation indicates it should return a Git::Object (which Git::Object::Commit is), rather than any ruby object. I would argue that anybody expecting a string at this point would be developing against an undocumented "feature" and shouldn't expect that to remain the case.

Having said that, I understand the concern about breaking existing APIs without a major version bump, so I can see arguments for both.

While this change does more accurately reflect the documentation and I feel is more intuitive than the current return value, I would be fine holding it for the next major version (I would still like to see this in a future version) with the caveat that the documentation be updated to reflect the current return value (which I would be happy to contribute to).

@jcouball
Copy link
Member

I wonder if the current state of generated docs for this project (where by default, everything returns a Git::Object) represents a bug in Yard? Yard documents that:

YARD defaults to displaying (Object) as the default return type of any method that has not declared a @return tag

However, it appears this Object is evaluated within the main module of the project (for example, the Git module for this project). Because of this, the return type Object is linked to Git::Object not because the documentation changed, but merely by the presence of Git::Object.

Nesting the Object class into a submodule does not have this behavior.

Removing Git::Object results in YARD documenting Object without a link, implying ::Object.

@jcouball
Copy link
Member

What do you think about this overall plan to deal with this issue? These steps would be done in this order:

  1. Immediately add a .yardopts file that sets the default return type of any method that has not declared a @return tag to ::Object. This can be done by including --default-return ::Object in the .yardopts file. That is my best guess as to the original intent.
  2. Over time, explicitly document the entire API for this gem using YARD
  3. Eventually reconsider what is returned for each method like Git::Base#commit

@stale
Copy link

stale bot commented Apr 17, 2020

A friendly reminder that this issue had no activity for 60 days.

@stale stale bot added the stale label Apr 17, 2020
@jcouball
Copy link
Member

Per the last comment, .yardopts has been configured not to document a return value when a @return directive has not been given for a method. Instead of ::Object, I have configured .yardopts to consider undocumented return values to be void which means that YARD should not show the return type in the documentation.

@jcouball jcouball closed this Dec 30, 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.

2 participants