Public Access
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2312c95dba | |||
| 7a06bcf403 | |||
| a8baf355c4 | |||
| 9520ce3bb8 | |||
| 120dbe3be2 | |||
| 657e6013de | |||
| c7a26c1ce1 | |||
| bdbabd9886 | |||
| e061537404 |
@@ -95,7 +95,7 @@ jobs:
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokocli
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokocli.git
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoCLI.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokocli
|
||||
cd /tmp/mokocli
|
||||
composer install --no-dev --no-interaction --quiet
|
||||
@@ -104,11 +104,39 @@ jobs:
|
||||
|
||||
- name: Rename branch to rc
|
||||
run: |
|
||||
php ${MOKO_CLI}/branch_rename.php \
|
||||
--from "${{ github.event.pull_request.head.ref || 'dev' }}" --to rc \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
--api-base "${MOKOGITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}" \
|
||||
--pr "${{ github.event.pull_request.number }}"
|
||||
API_BASE="${MOKOGITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
AUTH="Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}"
|
||||
FROM="${{ github.event.pull_request.head.ref || 'dev' }}"
|
||||
PR="${{ github.event.pull_request.number }}"
|
||||
|
||||
# Resolve the source branch HEAD commit.
|
||||
SRC_JSON=$(curl -sf -H "$AUTH" "${API_BASE}/branches/${FROM}") \
|
||||
|| { echo "::error::Source branch ${FROM} not found"; exit 1; }
|
||||
SRC_SHA=$(printf '%s' "$SRC_JSON" | python3 -c "import sys, json; print(json.load(sys.stdin)['commit']['id'])" 2>/dev/null || true)
|
||||
[ -n "$SRC_SHA" ] || { echo "::error::Could not resolve HEAD of ${FROM}"; exit 1; }
|
||||
|
||||
# Point rc at the source commit. If rc already exists (a protected branch that
|
||||
# cannot be deleted), force-update its ref in place instead of delete+recreate:
|
||||
# deleting a protected branch fails, which then makes the recreate return HTTP 409.
|
||||
if curl -sf -o /dev/null -H "$AUTH" "${API_BASE}/branches/rc"; then
|
||||
echo "rc exists - force-updating to ${FROM} (${SRC_SHA})"
|
||||
curl -sf -X PATCH -H "$AUTH" -H "Content-Type: application/json" \
|
||||
"${API_BASE}/git/refs/heads/rc" -d "{\"sha\":\"${SRC_SHA}\",\"force\":true}" \
|
||||
|| { echo "::error::Failed to force-update rc (CI token needs force-push on the protected rc branch)"; exit 1; }
|
||||
else
|
||||
echo "Creating rc from ${FROM}"
|
||||
curl -sf -X POST -H "$AUTH" -H "Content-Type: application/json" \
|
||||
"${API_BASE}/branches" -d "{\"new_branch_name\":\"rc\",\"old_branch_name\":\"${FROM}\"}" \
|
||||
|| { echo "::error::Failed to create rc from ${FROM}"; exit 1; }
|
||||
fi
|
||||
|
||||
# Repoint the PR at rc, then delete the old source branch (non-fatal).
|
||||
if [ -n "$PR" ]; then
|
||||
curl -s -X PATCH -H "$AUTH" -H "Content-Type: application/json" \
|
||||
"${API_BASE}/pulls/${PR}" -d '{"head":"rc"}' >/dev/null || true
|
||||
fi
|
||||
curl -s -X DELETE -H "$AUTH" "${API_BASE}/branches/${FROM}" >/dev/null || true
|
||||
echo "Renamed ${FROM} -> rc"
|
||||
|
||||
- name: Checkout rc and configure git
|
||||
run: |
|
||||
@@ -218,7 +246,7 @@ jobs:
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokocli
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokocli.git
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoCLI.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokocli
|
||||
cd /tmp/mokocli
|
||||
composer install --no-dev --no-interaction --quiet
|
||||
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
for BRANCH in $BRANCHES; do
|
||||
# Skip protected branches
|
||||
case "$BRANCH" in
|
||||
main|master|develop|release/*|hotfix/*) continue ;;
|
||||
main|master|dev|develop|rc|beta|alpha|release|release/*|production|stable|staging|hotfix/*|version/*) continue ;;
|
||||
esac
|
||||
|
||||
# Check if branch is merged into main
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: mokocli.Automation
|
||||
# VERSION: 09.42.00
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Auto-create feature branch when an issue is opened
|
||||
|
||||
name: "Universal: Issue Branch"
|
||||
|
||||
@@ -15,9 +15,9 @@ name: "Universal: Notifications"
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- "Joomla Build & Release"
|
||||
- "Joomla Extension CI"
|
||||
- "Deploy"
|
||||
- "Universal: Build & Release"
|
||||
- "Joomla: Extension CI"
|
||||
- "Generic: Project CI"
|
||||
types:
|
||||
- completed
|
||||
|
||||
|
||||
+9
-4
@@ -14,6 +14,15 @@ BRIEF: Release changelog
|
||||
|
||||
## [09.42.00] --- 2026-07-04
|
||||
|
||||
## [09.42.00] --- 2026-07-04
|
||||
|
||||
### Fixed
|
||||
- branch_rename.php: force-update the target branch ref in place instead of delete+recreate, so `moko repo:rename-branch` works when the target (e.g. `rc`) is a protected branch that cannot be deleted — previously the delete silently failed and the recreate returned HTTP 409
|
||||
|
||||
## [09.42.00] --- 2026-07-04
|
||||
|
||||
## [09.42.00] --- 2026-07-04
|
||||
|
||||
## [09.41.00] --- 2026-07-04
|
||||
|
||||
## [09.41.00] --- 2026-07-04
|
||||
@@ -22,7 +31,3 @@ BRIEF: Release changelog
|
||||
- RecoverySuggestion.php: remove stray shebang and wrap an over-length line to satisfy PSR-12 (Gate 1 phpcs)
|
||||
- phpstan-baseline.neon: baseline pre-existing PHPStan level-6 findings across `cli/`, `lib/`, and `validate/` so Gate 1 static analysis passes (type-annotation debt tracked, not silently ignored)
|
||||
- client_provision.php: rename private `printSummary()` (and its dispatch entry) to `printProvisioningSummary()` to stop it colliding with `CliFramework::printSummary()` — a non-baselineable PHPStan override/covariance error
|
||||
|
||||
## [09.41.00] --- 2026-07-04
|
||||
|
||||
## [09.41.00] --- 2026-07-04
|
||||
|
||||
+36
-16
@@ -64,26 +64,46 @@ class BranchRenameCli extends CliFramework
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Step 2: Delete target branch if it already exists
|
||||
// Step 2: Point the target branch at the source commit.
|
||||
// If the target already exists (e.g. a protected `rc` branch that cannot be
|
||||
// deleted), force-update its ref in place instead of delete+recreate: deleting a
|
||||
// protected branch fails, which then makes the recreate return HTTP 409.
|
||||
$sourceSha = '';
|
||||
if (isset($check['body']['commit']['id']) && is_string($check['body']['commit']['id'])) {
|
||||
$sourceSha = $check['body']['commit']['id'];
|
||||
}
|
||||
$targetCheck = $this->apiRequest('GET', "{$apiBase}/branches/{$to}", $headers);
|
||||
if ($targetCheck['code'] === 200) {
|
||||
echo "Target branch '{$to}' already exists — deleting\n";
|
||||
echo "Target branch '{$to}' already exists - force-updating to {$from}
|
||||
";
|
||||
if (!$this->dryRun) {
|
||||
$this->apiRequest('DELETE', "{$apiBase}/branches/{$to}", $headers);
|
||||
if ($sourceSha === '') {
|
||||
$this->log('ERROR', "Cannot resolve HEAD commit of source '{$from}'");
|
||||
return 1;
|
||||
}
|
||||
$ref = $this->apiRequest('PATCH', "{$apiBase}/git/refs/heads/{$to}", $headers, [
|
||||
'sha' => $sourceSha,
|
||||
'force' => true,
|
||||
]);
|
||||
if ($ref['code'] < 200 || $ref['code'] >= 300) {
|
||||
$this->log('ERROR', "Failed to force-update '{$to}': HTTP {$ref['code']} (needs force-push perm)");
|
||||
$this->log('ERROR', json_encode($ref['body']));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Create new branch from source
|
||||
echo "Creating branch: {$to} (from {$from})\n";
|
||||
if (!$this->dryRun) {
|
||||
$create = $this->apiRequest('POST', "{$apiBase}/branches", $headers, [
|
||||
'new_branch_name' => $to,
|
||||
'old_branch_name' => $from,
|
||||
]);
|
||||
if ($create['code'] < 200 || $create['code'] >= 300) {
|
||||
$this->log('ERROR', "Failed to create branch '{$to}': HTTP {$create['code']}");
|
||||
$this->log('ERROR', json_encode($create['body']));
|
||||
return 1;
|
||||
} else {
|
||||
echo "Creating branch: {$to} (from {$from})
|
||||
";
|
||||
if (!$this->dryRun) {
|
||||
$create = $this->apiRequest('POST', "{$apiBase}/branches", $headers, [
|
||||
'new_branch_name' => $to,
|
||||
'old_branch_name' => $from,
|
||||
]);
|
||||
if ($create['code'] < 200 || $create['code'] >= 300) {
|
||||
$this->log('ERROR', "Failed to create branch '{$to}': HTTP {$create['code']}");
|
||||
$this->log('ERROR', json_encode($create['body']));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user