|
| 1 | +# Git Hooks Plugin |
| 2 | + |
| 3 | +A marchat plugin that provides git repository management and status updates directly in your chat. |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +The Git Hooks Plugin allows users to interact with git repositories without leaving marchat. It provides commands for viewing git status, commit history, branches, and diffs, making it easy to monitor repository changes during conversations. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Git Status**: View the current status of your git repository |
| 12 | +- **Commit History**: Browse recent commits with author and time information |
| 13 | +- **Branch Management**: View current branch and available branches |
| 14 | +- **Diff Viewer**: See uncommitted changes at a glance |
| 15 | +- **Repository Watching**: Monitor repositories for changes (admin only) |
| 16 | + |
| 17 | +## Commands |
| 18 | + |
| 19 | +### User Commands |
| 20 | +- `:git-status [path]` — Show git status of current or specified directory |
| 21 | +- `:git-log [n] [path]` — Show recent git commits (default: 5) |
| 22 | +- `:git-branch [path]` — Show current branch and available branches |
| 23 | +- `:git-diff [path]` — Show git diff of uncommitted changes |
| 24 | + |
| 25 | +### Admin Commands |
| 26 | +- `:git-watch <path>` — Watch a repository for changes (admin only) |
| 27 | + |
| 28 | +## Installation |
| 29 | + |
| 30 | +### From Plugin Store |
| 31 | +```bash |
| 32 | +:store |
| 33 | +# Navigate to githooks plugin and press Enter to install |
| 34 | +``` |
| 35 | + |
| 36 | +### Direct Installation |
| 37 | +```bash |
| 38 | +:plugin install githooks |
| 39 | +``` |
| 40 | + |
| 41 | +## Build and Package |
| 42 | + |
| 43 | +Builds produce a single archive targeted to your OS/architecture. |
| 44 | + |
| 45 | +### PowerShell (Windows) |
| 46 | +```powershell |
| 47 | +# From this directory |
| 48 | +./build.ps1 -Version 1.0.0 -Os windows -Arch amd64 |
| 49 | +# Output: dist/githooks-plugin-v1.0.0-windows-amd64.zip and .sha256 |
| 50 | +``` |
| 51 | + |
| 52 | +### Bash (Linux/macOS) |
| 53 | +```bash |
| 54 | +# From this directory |
| 55 | +VERSION=1.0.0 bash build.sh # uses GOOS/GOARCH from env |
| 56 | +# or override |
| 57 | +VERSION=1.0.0 GOOS=linux GOARCH=amd64 bash build.sh |
| 58 | +VERSION=1.0.0 GOOS=darwin GOARCH=amd64 bash build.sh |
| 59 | +VERSION=1.0.0 GOOS=darwin GOARCH=arm64 bash build.sh |
| 60 | +# Output: dist/githooks-plugin-v1.0.0-{os}-{arch}.zip and .sha256 |
| 61 | +``` |
| 62 | + |
| 63 | +### Archive Contents |
| 64 | +- `githooks` or `githooks.exe` — the plugin binary |
| 65 | +- `plugin.json` — plugin manifest with metadata and commands |
| 66 | +- `README.md` — this documentation |
| 67 | + |
| 68 | +### Naming Convention |
| 69 | +- `githooks-plugin-v<version>-<goos>-<goarch>.zip` |
| 70 | + - Examples: `githooks-plugin-v1.0.0-windows-amd64.zip`, `githooks-plugin-v1.0.0-darwin-arm64.zip` |
| 71 | + |
| 72 | +## Usage Examples |
| 73 | + |
| 74 | +### Check Git Status |
| 75 | +```bash |
| 76 | +:git-status |
| 77 | +# Output: Shows status of current directory |
| 78 | + |
| 79 | +:git-status /path/to/repo |
| 80 | +# Output: Shows status of specified repository |
| 81 | +``` |
| 82 | + |
| 83 | +### View Recent Commits |
| 84 | +```bash |
| 85 | +:git-log |
| 86 | +# Output: Shows last 5 commits |
| 87 | + |
| 88 | +:git-log 10 |
| 89 | +# Output: Shows last 10 commits |
| 90 | + |
| 91 | +:git-log 10 /path/to/repo |
| 92 | +# Output: Shows last 10 commits for specified repo |
| 93 | +``` |
| 94 | + |
| 95 | +### View Branches |
| 96 | +```bash |
| 97 | +:git-branch |
| 98 | +# Output: Shows current branch and all branches |
| 99 | + |
| 100 | +:git-branch /path/to/repo |
| 101 | +# Output: Shows branches for specified repository |
| 102 | +``` |
| 103 | + |
| 104 | +### View Uncommitted Changes |
| 105 | +```bash |
| 106 | +:git-diff |
| 107 | +# Output: Shows diff statistics for uncommitted changes |
| 108 | + |
| 109 | +:git-diff /path/to/repo |
| 110 | +# Output: Shows diff for specified repository |
| 111 | +``` |
| 112 | + |
| 113 | +### Watch Repository (Admin Only) |
| 114 | +```bash |
| 115 | +:git-watch /path/to/repo |
| 116 | +# Output: Now watching repository: /path/to/repo |
| 117 | +``` |
| 118 | + |
| 119 | +## Plugin Management |
| 120 | + |
| 121 | +### List Installed Plugins |
| 122 | +```bash |
| 123 | +:plugin list |
| 124 | +``` |
| 125 | + |
| 126 | +### Enable/Disable Plugin |
| 127 | +```bash |
| 128 | +:plugin enable githooks |
| 129 | +:plugin disable githooks |
| 130 | +``` |
| 131 | + |
| 132 | +### Uninstall Plugin (Admin Only) |
| 133 | +```bash |
| 134 | +:plugin uninstall githooks |
| 135 | +``` |
| 136 | + |
| 137 | +## Technical Details |
| 138 | + |
| 139 | +### Plugin Structure |
| 140 | +``` |
| 141 | +githooks/ |
| 142 | +├── githooks (.exe) # Binary executable |
| 143 | +├── plugin.json # Plugin manifest |
| 144 | +└── README.md # This documentation |
| 145 | +``` |
| 146 | + |
| 147 | +### Requirements |
| 148 | +- Git must be installed and available in PATH |
| 149 | +- Plugin will verify git availability during initialization |
| 150 | +- Repository paths must contain a valid `.git` directory |
| 151 | + |
| 152 | +### Git Commands Used |
| 153 | +- `git status --short --branch` - Repository status |
| 154 | +- `git log --pretty=format` - Commit history |
| 155 | +- `git branch --show-current` - Current branch |
| 156 | +- `git branch -a` - All branches |
| 157 | +- `git diff --stat` - Change statistics |
| 158 | + |
| 159 | +## Version History |
| 160 | + |
| 161 | +- **v1.0.0** - Initial release with git status, log, branch, diff, and watch commands |
| 162 | + |
| 163 | +## License |
| 164 | + |
| 165 | +MIT License - see [LICENSE](../../LICENSE) for details. |
| 166 | + |
| 167 | +## Contributing |
| 168 | + |
| 169 | +This plugin is part of the marchat-plugins project. For plugin development guidelines, see the main repository's [CONTRIBUTING.md](../../CONTRIBUTING.md). |
| 170 | + |
| 171 | +## Support |
| 172 | + |
| 173 | +For issues or questions about this plugin: |
| 174 | +- Create an issue in the [marchat-plugins repository](https://github.com/Cod-e-Codes/marchat-plugins/issues) |
| 175 | +- Check the [plugin documentation](https://github.com/Cod-e-Codes/marchat/blob/main/PLUGIN_ECOSYSTEM.md) |
| 176 | + |
| 177 | +## Security Notes |
| 178 | + |
| 179 | +- Admin-only commands (git-watch) require proper authorization |
| 180 | +- Plugin validates repository paths and git directory existence |
| 181 | +- All git commands run with user's current permissions |
| 182 | +- No git write operations are performed (read-only) |
| 183 | + |
| 184 | +--- |
| 185 | + |
| 186 | +**Note**: This plugin executes git commands on your system. Ensure you trust the repositories you're querying and have proper access permissions. |
| 187 | + |
0 commit comments