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

Revise index-tags script #742

Merged
merged 2 commits into from
Feb 18, 2021

Conversation

bmckeough-showcaseidx
Copy link
Contributor

@bmckeough-showcaseidx bmckeough-showcaseidx commented Feb 8, 2021

  • use git rev-parse --git-dir instead of $GIT_DIR to identify the git directory

- based what files are included in tag generation on the files managed
by git. Exclude files not managed by git
@bmckeough-showcaseidx
Copy link
Contributor Author

I was prompted to make this change because the index-tags script was not working for me. The $GIT_DIR environment variable was not populated, and so the script failed with "cat: /ctags.err: No such file or directory". Note that because the script is executed in the background and output is redirected to temporary files I had to pause the process in order to view the error output. That is, when the overcommit IndexTag hook is triggered it does not report a failure or error.

Git versions: 2.30.0
OS: macOS Catalina (10.15.7)
Shell: zsh 5.7.1 (x86_64-apple-darwin19.0)

@sds
Copy link
Owner

sds commented Feb 12, 2021

Thanks for the pull request, @bmckeough-showcaseidx.

Can you elaborate on why you made the second change? Developers may want to have ctags run without filtering to the files tracked by Git because there may be auto-generated files/etc. that they still want to be able to jump to definitions for. Filtering to files that are tracked by Git prevents this workflow.

Happy to merge without the filtering.

@bmckeough-showcaseidx
Copy link
Contributor Author

I reverted the ctags command to recursively tag all files.

My best recollection of why I preferred limiting tagging to files managed by git is that I have several repositories with large node_modules directories. I don't rely on tags for those files, and so preferred not generating tags for them.

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.

I'm supportive of you adding support for making ignoring files not tracked by Git an option for the hook, if you would like to see that added.

@sds sds merged commit 6b25f5d into sds:master Feb 18, 2021
@sds
Copy link
Owner

sds commented Feb 18, 2021

Thanks!

@bmckeough-showcaseidx
Copy link
Contributor Author

@sds Would you be receptive to a PR that parameterizes the index-tags script executed by IndexTags? If so, do you have any pointers on the appropriate way to make IndexTags accept a parameter that specifies the location of the index-tags script?

I'm imagining the ability to configure Overcommit to execute an indexing script of my chosing for each repository in which I use Overcommit. I imaging Overcommit would still supply the default libexec/index-tags script, but that this could be overridden by the user.

@sds
Copy link
Owner

sds commented Mar 3, 2021

Very receptive!

Have a look at:

execute_in_background([Overcommit::Utils.script_path('index-tags')])

Notice execute_in_background takes an array of arguments. You could construct additional arguments to pass in based on the config for the hook, and then modify the script to use those arguments.

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.

None yet

2 participants