feat(git-control): add branch compare (main/uat/prod), org/single repo support
Made-with: Cursor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: git-control
|
||||
description: Gitea repository and branch access control. Use when managing Git permissions: enable/disable branch protection (push, merge, read), user read/write permissions on repos, organization-wide repo access, listing orgs/repos, or bulk permission changes. Supports Gitea API (e.g. afe.git:3000).
|
||||
description: Gitea repository and branch access control. Use when managing Git permissions: enable/disable branch protection (push, merge, read), user read/write permissions on repos, organization-wide repo access, listing orgs/repos, bulk permission changes, or comparing branches to detect unmerged commits (e.g. prod hotfix not in main). Supports Gitea API (e.g. afe.git:3000).
|
||||
---
|
||||
|
||||
# Git Control (Gitea)
|
||||
@@ -59,7 +59,7 @@ Add, remove, or change a user's permission on a repo.
|
||||
.\scripts\user_permission.ps1 -ApiToken "..." -Owner G3SF -Repo g3fo-trade -Username john -Action revoke
|
||||
```
|
||||
|
||||
### 4. Org-Wide Repo Protection
|
||||
### 5. Org-Wide Repo Protection
|
||||
|
||||
Apply branch protection to all repos under an organization.
|
||||
|
||||
@@ -67,7 +67,42 @@ Apply branch protection to all repos under an organization.
|
||||
.\scripts\org_repos_protect.ps1 -ApiToken "..." -Org G3SF -BranchName uat -Action lock
|
||||
```
|
||||
|
||||
### 5. Org-Wide User Access
|
||||
### 6. Branch Compare (Detect Unmerged Commits)
|
||||
|
||||
Analyze differences between branches to find commits that need merging (e.g. prod hotfix not merged to main).
|
||||
|
||||
| Mode | Script | Use Case |
|
||||
|------|--------|----------|
|
||||
| Single repo (local) | `branch_compare.ps1 -RepoPath` | Repo cloned locally |
|
||||
| Single repo (API) | `branch_compare.ps1 -Owner -Repo` | No local clone |
|
||||
| Single repo | `org_branch_compare.ps1 -Repo g3fo-trade` | One repo by name |
|
||||
| Org-wide | `org_branch_compare.ps1` | All repos in org |
|
||||
|
||||
**CompareSet**:
|
||||
- `single`: BaseBranch vs HeadBranch only (default for branch_compare)
|
||||
- `full`: main vs uat, main vs prod, uat vs prod (default for org_branch_compare)
|
||||
|
||||
```powershell
|
||||
# Single repo - full check (main/uat/prod)
|
||||
.\scripts\branch_compare.ps1 -RepoPath "d:\path\to\g3fo-trade" -CompareSet full
|
||||
.\scripts\branch_compare.ps1 -Owner G3SF -Repo g3fo-trade -CompareSet full
|
||||
|
||||
# Single pair
|
||||
.\scripts\branch_compare.ps1 -RepoPath "d:\path\to\repo" -BaseBranch main -HeadBranch uat
|
||||
|
||||
# Single repo by name (org)
|
||||
.\scripts\org_branch_compare.ps1 -Org G3SF -Repo g3fo-trade -CompareSet full
|
||||
|
||||
# All G3SF repos - full check
|
||||
.\scripts\org_branch_compare.ps1 -Org G3SF -CompareSet full -WorkspaceRoot "d:\AFE Git\G3SF\G3FO\server"
|
||||
|
||||
# Filter by date or tag
|
||||
.\scripts\branch_compare.ps1 -RepoPath "d:\path\to\repo" -CompareSet full -SinceDate "2025-01-01"
|
||||
```
|
||||
|
||||
**Output**: Commits in `HeadBranch` NOT in `BaseBranch` = need to merge (hotfixes). Commits in `BaseBranch` NOT in `HeadBranch` = base is ahead (normal).
|
||||
|
||||
### 7. Org-Wide User Access
|
||||
|
||||
Revoke or grant a user's collaborator access across all org repos.
|
||||
|
||||
@@ -84,6 +119,7 @@ Note: Org repos often use team permissions. For team-based access, use Gitea API
|
||||
|----------|-------------|
|
||||
| **Lock UAT for release** | Lock `uat` branch on specified repos before release freeze |
|
||||
| **Unlock for merge** | Temporarily allow merge (add user to merge allowlist) |
|
||||
| **Detect unmerged hotfixes** | Compare prod vs main to find commits in prod not in main |
|
||||
| **Audit user access** | List repos a user can access (collaborators + org teams) |
|
||||
| **Bulk branch lock** | Lock same branch across multiple repos |
|
||||
| **Read-only maintenance** | Set repo to read-only during maintenance |
|
||||
|
||||
Reference in New Issue
Block a user