Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perforce client side pre-commit hook

We are using perforce as a source control for Visual studio solution. Working with P4 and P4V. Is it possible to add client side pre-commit hook? for instance to ensure the word "debugger;" is not exist in *.js files. Could find something in Google. Thanks.

like image 505
Igal Avatar asked Apr 17 '13 06:04

Igal


People also ask

How do you put a pre-commit on a hook?

Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.

Can you commit pre-commit hooks?

pre-commit will now run on every commit. Every time you clone a project using pre-commit running pre-commit install should always be the first thing you do. If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> .

How do you avoid pre-commit hooks?

Quick tip if you want to skip the pre-commit validations and quickly want to get a commit out there. To get your commit through without running that pre-commit hook, use the --no-verify option. Voila, without pre-commit hooks running!

What is pre-commit hook?

The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.


1 Answers

Perforce triggers can be used to enforce such a policy, but they run in the server, not client-side. So most sites that I'm aware of would enforce a rule such as the one you describe using a change-content trigger in the server.

http://www.perforce.com/perforce/doc.current/manuals/cmdref/triggers.html

It's not obvious from your question why you need to have a client-side hook. Is there some reason you don't want to use a change-content trigger?

Perhaps you might consider re-framing your workflow as a code review process, and implement policies like this in your code review tool of choice.

like image 148
Bryan Pendleton Avatar answered Oct 06 '22 00:10

Bryan Pendleton