Skip to content

HauptJ/Value-Cleaner

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Value-Cleaner

Build Status

  • Linux: Build Status

Git pre and post commit hooks to remove values for private variables during commits. Before the files are commited, the pre-commit hook copies the original files to a temporary backup directory outside of the Git repository and then removes the values for specified variables. For example, the value of any variable that ends with _secret will be replaced with replace_me before it is commited. After the commit, the modified files will be restored using the files that were backed up.

Usage

Copy the pre-commit, post-commit hooks the cmnds.py and the py-hook files to the git_hooks directory. Modify the pre-commit and post-commit hooks with your paramaters.

Pre-Commit

Modify the command listed in pre-commit as follows:

"pre" "source directory" "../backup directory" ".file extension" "_secret:.*" "_secret: replace_me"

Note 1: The variables that you want to replace the values for should be tagged with an identifier such as _secret. For example: api_key_secret: API_key will be replaced with api_key_secret: replace_me.

Note 2: Regular Expressions are used with to find the value to substitute / replace. For example if you use: _secret:.* , the content of the line starting with _secret: will be replaced be replaced with replace_me. If you use .* regular expression, you may want to use something link this: "_secret:.*" "_secret: replace_me"

Regex Cheat Sheet

Note 3: If the text file does not have an extension, you should use "" as the paramater.

Note 4: The backup directory must not be in the git repository and as a safeguard, the paramater must include .. at the beginning. For example: "../backup.dir

Post-Commit

Modify the command listed in post-commit as follows:

"post" "source directory" "../backup directory"

About

Git pre and post commit hooks to remove values for private variables.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages