feat(worktrees): création intelligente (auto) + commit/push/promotion + grille agrandissable
- addWorktree résout la branche par dépôt (branchExists) : checkout si présente, suivi de origin/<b> si seulement remote, sinon création (-b) depuis la branche par défaut. Corrige le 'fatal: invalid reference' sur les groupes hétérogènes ; newBranch -> mode (déprécié, mappé en route).
- Nouvelles opérations git : commit (add -A), push (upstream auto), promotion « en principal » (la branche du worktree devient le checkout principal, sans merge ni conflit, ancienne branche conservée). Routes /worktrees/{commit,push,promote} auditées + GET /repos/:id/branches.
- Web : actions Commit/Push/Promouvoir sur WorktreeCard, sélecteur de branche de base (datalist) dans RepoSection et GroupSessionModal, agrandissement d'un terminal au choix dans TerminalGrid.
- Court-circuite la session de groupe quand aucun worktree n'a pu être créé (fini le masquage par « no resolvable worktree »).
- Tests : git.ts (branchExists/listBranches/commitAll/auto), worktree-manager (commit/promote/branches) ; acceptance P5 étend le scénario worktree de groupe sur branche neuve + commit + promotion.
This commit is contained in:
@@ -27,12 +27,19 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-end gap-2">
|
||||
<!-- mode worktree : branche + créer/existante -->
|
||||
<!-- mode worktree : branche (créée si absente, réutilisée si présente) + branche de base + session -->
|
||||
<template v-if="mode === 'worktree'">
|
||||
<label class="flex flex-1 flex-col gap-1 text-xs text-zinc-400">
|
||||
{{ t('worktrees.branch') }}
|
||||
<input v-model="branch" class="input font-mono" placeholder="feature/…" required />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-xs text-zinc-400">
|
||||
{{ t('worktrees.baseRefLabel') }}
|
||||
<input v-model="baseRef" class="input font-mono" :list="datalistId" :placeholder="t('worktrees.baseRefPlaceholder')" />
|
||||
<datalist :id="datalistId">
|
||||
<option v-for="b in baseBranchOptions" :key="b" :value="b" />
|
||||
</datalist>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-xs text-zinc-400">
|
||||
{{ t('worktrees.start') }}
|
||||
<select v-model="startSession" class="input">
|
||||
@@ -41,7 +48,6 @@
|
||||
<option value="bash">bash</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex items-center gap-1 text-xs text-zinc-400"><input v-model="newBranch" type="checkbox" /> {{ t('worktrees.newBranch') }}</label>
|
||||
</template>
|
||||
|
||||
<!-- mode branche principale : option git (branche actuelle ou nouvelle branche) + commande -->
|
||||
@@ -81,10 +87,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Eye, EyeOff, Plus, Scissors, Trash2 } from '@lucide/vue';
|
||||
import type { RepoSummary } from '@arboretum/shared';
|
||||
import type { RepoBranchesResponse, RepoSummary } from '@arboretum/shared';
|
||||
import { useWorktreesStore } from '../stores/worktrees';
|
||||
import { useWorktreeView } from '../composables/useWorktreeView';
|
||||
import { useToastsStore } from '../stores/toasts';
|
||||
@@ -103,13 +109,30 @@ const worktrees = computed(() => view.apply(store.worktreesForRepo(props.repo.id
|
||||
const creating = ref(false);
|
||||
const mode = ref<'worktree' | 'main'>('worktree');
|
||||
const branch = ref('');
|
||||
const newBranch = ref(true);
|
||||
const baseRef = ref('');
|
||||
const startSession = ref<'claude' | 'bash' | null>(null);
|
||||
const mainBranchMode = ref<'current' | 'new'>('current');
|
||||
const mainCommand = ref<'claude' | 'bash'>('claude');
|
||||
const busy = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
|
||||
// Sélecteur de branche de base (chargé paresseusement à l'ouverture du formulaire).
|
||||
const branches = ref<RepoBranchesResponse | null>(null);
|
||||
const datalistId = computed(() => `wt-base-branches-${props.repo.id}`);
|
||||
const baseBranchOptions = computed<string[]>(() => {
|
||||
const b = branches.value;
|
||||
if (!b) return [];
|
||||
return Array.from(new Set([...(b.default ? [b.default] : []), ...b.local, ...b.remote]));
|
||||
});
|
||||
watch(creating, async (open) => {
|
||||
if (!open || branches.value) return;
|
||||
try {
|
||||
branches.value = await store.fetchBranches(props.repo.id);
|
||||
} catch {
|
||||
/* le sélecteur de base est facultatif */
|
||||
}
|
||||
});
|
||||
|
||||
// worktree : branche obligatoire ; branche principale + nouvelle branche : branche obligatoire ; sinon OK.
|
||||
const canSubmit = computed(() =>
|
||||
mode.value === 'worktree' ? branch.value.trim() !== '' : mainBranchMode.value === 'current' || branch.value.trim() !== '',
|
||||
@@ -120,7 +143,12 @@ async function onCreate(): Promise<void> {
|
||||
error.value = null;
|
||||
try {
|
||||
if (mode.value === 'worktree') {
|
||||
await store.createWorktree(props.repo.id, { branch: branch.value.trim(), newBranch: newBranch.value, startSession: startSession.value });
|
||||
await store.createWorktree(props.repo.id, {
|
||||
branch: branch.value.trim(),
|
||||
mode: 'auto', // détecte créer / checkout / suivi remote
|
||||
...(baseRef.value.trim() ? { baseRef: baseRef.value.trim() } : {}),
|
||||
startSession: startSession.value,
|
||||
});
|
||||
toasts.success(t('toast.worktreeCreated'));
|
||||
} else {
|
||||
// bosser sur la branche principale : session dans le checkout principal, avec création de branche optionnelle.
|
||||
@@ -131,6 +159,7 @@ async function onCreate(): Promise<void> {
|
||||
toasts.success(t('toast.sessionCreated'));
|
||||
}
|
||||
branch.value = '';
|
||||
baseRef.value = '';
|
||||
creating.value = false;
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : String(err);
|
||||
|
||||
Reference in New Issue
Block a user