/**
 * GET /api/applications/:id/git/status
 *
 * Returns the live snapshot of the application's local working tree —
 * branch, uncommitted count, unpushed count, has-remote flag, remote URL.
 * Polled every few seconds by the SmartDeployButton hook so the label
 * reacts to drift without a manual refresh.
 */
import { NextResponse } from 'next/server';
import { resolve } from '../../../../../../lib/server-container.js';
import { errorCode, errorMessage } from '../../../../../../lib/error-code.js';
export const dynamic = 'force-dynamic';
export async function GET(_request, { params }) {
    try {
        const { id } = await params;
        const useCase = resolve('GetGitStatusUseCase');
        const status = await useCase.execute({ applicationId: id });
        return NextResponse.json(status);
    }
    catch (error) {
        const code = errorCode(error);
        const message = errorMessage(error);
        if (code === 'APPLICATION_NOT_FOUND') {
            return NextResponse.json({ error: message, code }, { status: 404 });
        }
        return NextResponse.json({ error: message, code }, { status: 500 });
    }
}
