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

Add pronto to pre_push hooks #706

Merged
merged 2 commits into from
Mar 8, 2020

Conversation

povilasjurcys
Copy link
Contributor

Currently it's possible to add pronto only as PreCommit hook. This PR allows to add pronto as PrePush hook too.

Copy link
Owner

@sds sds left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request @povilasjurcys.

Overall looks good, but I'm not clear on the need for protected.

@@ -10,7 +10,7 @@ class Base < Overcommit::Hook::Base

def_delegators :@context, :modified_lines_in_file, :amendment?, :initial_commit?

private
protected
Copy link
Owner

Choose a reason for hiding this comment

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

Can you explain why we're making this change when the previous private worked?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

extract_messages is used in child classes.

private" means that only methods of this class can access the member. "protected" means that methods of this class, or of derived classes, can access the member.
source: https://answers.unity.com/questions/610093/what-is-the-difference-between-private-and-protect.html

Just wanted to handle this in more "correct" way. Ruby does dot handle private and protected very well anyways, but I personally use protected when I want to indicate that method might be overwritten in child class. Sadly, in practice you can do the same with private methods too.

Let me know if you prefer private more.

Copy link
Owner

Choose a reason for hiding this comment

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

You are referencing documentation for a language that is not Ruby. protected, in a nutshell, allows a method to be called by another instance of the same class or subclass. It is not necessary in this context.

From https://ruby-doc.org/core-2.5.3/Module.html#method-i-protected

If a method has protected visibility, it is callable only where self of the context is the same as the method. (method definition or instance_eval). This behavior is different from Java's protected method. Usually private should be used.

Emphasis mine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for pointing this out. You're right. private it is

@@ -15,6 +16,12 @@ def run?
(include_remote_ref_deletions? || !@context.remote_ref_deletion?)
end

protected
Copy link
Owner

Choose a reason for hiding this comment

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

Why are we using protected? There isn't a situation where another instance is attempting to call this method, so private is the correct level of access control. If I'm misunderstanding your intent, let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sds sds added the enhancement label Mar 1, 2020
@sds sds merged commit 16eded3 into sds:master Mar 8, 2020
@sds
Copy link
Owner

sds commented Mar 8, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants