Skip to content

Code Improvements #23

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 7 commits into from
Jun 1, 2018
Merged

Conversation

joaorobertopb
Copy link
Contributor

@joaorobertopb joaorobertopb commented May 31, 2018

This PR will:

  • Code cleanup.
  • Add helpers.php file:
    • git_version() function. (Avoid updating the application version)
    • mkdir_if_not_exist() function. (DRY concept)
    • windows_os() function. (DRY concept)

- DRY ( Don't repeat yourself concept )
- DRY ( Don't repeat yourself concept )
- Avoid updating the application version in future releases
src/helpers.php Outdated
*
* @return void
*/
function mkdir_if_not_exist($dir, $mode = 0700, $recursive = true)
Copy link
Owner

Choose a reason for hiding this comment

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

since this function is only relevant for creating hooks, I would prefer something like create_hooks_dir. That way, we would only need to pass in $gitDir at the call sites. We can all just remove the other arguments and hardcode in the mkdir call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay!

src/helpers.php Outdated
*
* @return bool
*/
function windows_os()
Copy link
Owner

Choose a reason for hiding this comment

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

maybe is_windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay!

- 'windos_os()' to 'is_windows()'
- 'mkdir_if_not_exist()' to 'create_hooks_dir()'
-  Replace mkdir hardcode with 'create_hooks_dir()' function
if (! is_dir($hookDir)) {
mkdir($hookDir, 0700, true);
}
create_hooks_dir("{$gitDir}/hooks");
Copy link
Owner

Choose a reason for hiding this comment

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

last nitpick: I would prefer create_hooks_dir($gitDir); and then the string interpolation will happen in the function. that removes some redundancy. what do you think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, much better! I did not pay attention to this before 😅, I'll make the change.

- String interpolation within function
@joaorobertopb
Copy link
Contributor Author

Done!

Much better now! That's why I love the code review 😍...

With all these changes, do you consider launching a new release? maybe 2.5.

Copy link
Owner

@BrainMaestro BrainMaestro left a comment

Choose a reason for hiding this comment

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

Great work! Already much cleaner

@BrainMaestro
Copy link
Owner

Yeah I might do a release

@BrainMaestro BrainMaestro merged commit d3ba750 into BrainMaestro:master Jun 1, 2018
*/
function git_version()
{
$process = new Process('git describe --tags $(git rev-list --tags --max-count=1)');
Copy link
Contributor

Choose a reason for hiding this comment

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

This now requires symfony/process as a project dependancy, right?

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.

3 participants