This README documents the internal git automation scripts and GitHub workflows used in the CoCode project. These tools help manage branch operations securely and streamline team workflows while ensuring safe and intentional Git history modifications.
All scripts include a local authorization mechanism:
- Token-based Auth: You must export
GIT_SCRIPT_MASTER_TOKENin your environment. - Trusted Mode: Once authenticated, you can run
grant-trust.shto skip prompts until revoked. - Encrypted Storage: Token is stored securely in
~/.git-script-authand decrypted on demand viasetup.token.sh.
Token Setup:
./setup-token.sh # Only authorized users can run thisNote: The token is automatically loaded only when you're in the CoCode repository directory. This prevents the GPG passphrase prompt from appearing in every terminal session globally.
Fix Existing Installation:
If you previously ran setup-token.sh and are getting passphrase prompts globally, run:
./fix-bashrc.sh # Removes global export and adds repo-specific check- Merges a source branch into all other branches, skipping those ahead or diverged.
- Supports:
-c/--current(use current branch)--dry-run(simulation)--exclude <branches>
Example:
./merge-to-all.sh -c --dry-run --exclude main dev- Resets or fast-forwards multiple branches with optional remote push.
- Skips protected branches unless
--include-protectedis specified.
Supports:
--reverse <n>--forward <n> --base <branch>--include-protected--update-remote--log logfile.txt
Example:
./realign-branches.sh --forward 3 --base dev --exclude main --dry-run- Locally creates
.internal/authorized.flagallowing scripts to run without repeated token prompts. - Only executable by authorized users (chmod restricted).
- Deletes the trust flag. Scripts will prompt for token again.
- Sends formatted commit summaries to a Discord webhook on
mainandfeatures/**pushes. - Includes:
- Branch name
- Author
- Commit message(s)
- File change stats (first 10 lines)
- On every push, it posts a branch summary to Discord.
- Shows each branch’s:
- HEAD status
- SHA hash
- Ahead/behind compared to
main
/scripts
merge-to-all.sh
realign-branches.sh
grant-trust.sh
revoke-trust.sh
setup.token.sh
/.internal
authorize.sh
authorized.flag (generated)
get-token.sh
| Script | Auth Required | Only authorized user? | Notes |
|---|---|---|---|
| setup.token.sh | Yes | Yes | Stores and encrypts token |
| authorize.sh | Runtime | No | Validates token when needed |
| grant-trust.sh | Yes | Yes | Enables trusted flag locally |
| revoke-trust.sh | No | No | Clears trust flag |
| merge-to-all.sh | Yes | No | Merges branches (safe rules) |
| realign-branches.sh | Yes | No | Force reset/FF with warnings |
- Run
setup.token.shto configure your personal token. - Use
export GIT_SCRIPT_MASTER_TOKEN=$(~/.git-script-auth/get-token.sh)in.bashrc. - Use
grant-trust.shto enable trusted script usage (optional). - Use
revoke-trust.shto disable auto-authorization. - Scripts will now run securely and respect access.