Skip to content

✨🌏Add global#6

Open
tiffafoo wants to merge 2 commits intomasterfrom
feature/global
Open

✨🌏Add global#6
tiffafoo wants to merge 2 commits intomasterfrom
feature/global

Conversation

@tiffafoo
Copy link
Copy Markdown
Owner

@tiffafoo tiffafoo commented Aug 26, 2018

Description

WIP adds --global and handles when there is are already precommit/prepare-commit-msg hooks.

Motivation and Context

Closes #4 and #5

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

Not yet, just locally

Checklist:

  • I have checked that no other PR duplicates mine
  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

const homedir = require('os').homedir();

// Takes the commit message and runs it through commoji
const commojiHook = `#!/bin/sh
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like it wouldn't work if the user isn't at the root of a project.
You might want to use git rev-parse --show-toplevel of $PWD to get the .git directory of a project.

try {
// Synchronously test the user's permissions for the file
// F_OK: Constant for fs.access(). File is visible to the calling process
fs.accessSync(gitHooksPath, fs.constants.F_OK);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would suggest against checking a fixed path for git templates. Many users reinstall git on macos to update from the built-in version of git.

Instead, running git config --global core.hooksPath without arguments would return a pre-existing hooks path if there is one already defined and used:

image

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

core.hooksPath doesn't exist on certain versions of git, the given gitHooksPath is the default one where hooks are made from what I understood, we can tell the user to specify it.

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.

Add global integration

2 participants