diff --git a/PBIDE-GitTool.pb b/PBIDE-GitTool.pb index 423f76e..cfdb471 100644 --- a/PBIDE-GitTool.pb +++ b/PBIDE-GitTool.pb @@ -128,6 +128,8 @@ Declare.i ConfigIdentityWizard(repoDir$) Declare.i MakeDefaultGitignore(repoDir$) Declare.i UpdateGuide(repoDir$, List rows.FileRow(), branch$, remote$) Declare.s GetLocalConfig(repoDir$, key$) +Declare.i IsGitRepo(dir$) +Declare.i UpdateGuide(repoDir$, List rows.FileRow(), branch$, remote$) ; ====== Utils ====== Procedure.s TrimNewlines(text$) @@ -731,45 +733,108 @@ Procedure.i MakeDefaultGitignore(repoDir$) ProcedureReturn 0 EndProcedure +; Vérifie si 'dir$' est un dépôt Git +; - essaie via 'git rev-parse --is-inside-work-tree' +; - fallback: présence du dossier .git +Procedure.i IsGitRepo(dir$) + Protected gc.GitCall + Protected isRepo.i = 0 + Protected dotGitDir$ = dir$ + + If Right(dotGitDir$, 1) <> #PathSep$ + dotGitDir$ + #PathSep$ + EndIf + dotGitDir$ + ".git" + + gc\workdir = dir$ + gc\args = "rev-parse --is-inside-work-tree" + If RunGit(@gc) = 0 + If FindString(LCase(TrimNewlines(gc\output)), "true", 1) + isRepo = 1 + EndIf + Else + ; Fallback : dossier .git présent ? + If FileSize(dotGitDir$) = -2 + isRepo = 1 + EndIf + EndIf + + If #EnableDebug + Debug "[IsGitRepo] " + dir$ + " -> " + Str(isRepo) + EndIf + + ProcedureReturn isRepo +EndProcedure + + +; Met à jour le panneau "Guide" avec un pas-à-pas adapté +; - Inclut l’étape “Init repo” si le dossier n’est pas encore un dépôt +; - Rappelle la différence Commit / Push pour débutants Procedure.i UpdateGuide(repoDir$, List rows.FileRow(), branch$, remote$) Protected tips$ = "" Protected hasChanges.i = 0 + Protected name$ = GetLocalConfig(repoDir$, "user.name") + Protected mail$ = GetLocalConfig(repoDir$, "user.email") + Protected repoReady.i = IsGitRepo(repoDir$) + + ; Y a-t-il des lignes dans le status ? ForEach rows() hasChanges = 1 Break Next - Protected name$ = GetLocalConfig(repoDir$, "user.name") - Protected mail$ = GetLocalConfig(repoDir$, "user.email") - tips$ + "Bienvenue !" + #LF$ - tips$ + "- Si vous débutez, suivez ces étapes :" + #LF$ + #LF$ - tips$ + "1) " + Chr(149) + " Vérifiez que l'identité Git est configurée (bouton 'Configurer identité…')." + #LF$ - If name$ = "" Or mail$ = "" - tips$ + " → Identité actuelle : INCOMPLÈTE." + #LF$ - Else - tips$ + " → Identité : " + name$ + " <" + mail$ + ">" + #LF$ - EndIf + tips$ + "- Ce panneau vous guide pas à pas." + #LF$ + #LF$ - tips$ + "2) " + Chr(149) + " Optionnel : créez un '.gitignore' (bouton dédié) pour ignorer les fichiers de compilation." + #LF$ - tips$ + "3) " + Chr(149) + " Cochez dans la liste les fichiers à inclure au commit." + #LF$ - If hasChanges - tips$ + " → Des modifications sont détectées ci-dessus." + #LF$ - Else - tips$ + " → Aucune modification à committer pour l’instant." + #LF$ - EndIf + If repoReady = 0 + ; ---- Dépôt non initialisé : on commence par git init ---- + tips$ + "Étapes de départ :" + #LF$ + tips$ + "1) " + Chr(149) + " Cliquez sur le bouton 'Init repo' pour INITIALISER le dépôt dans ce dossier." + #LF$ + tips$ + "2) " + Chr(149) + " (Recommandé) Créez un '.gitignore' avec le bouton dédié, pour ignorer les binaires/artefacts." + #LF$ + tips$ + "3) " + Chr(149) + " Configurez votre identité (bouton 'Configurer identité…')." + #LF$ + tips$ + "4) " + Chr(149) + " Cochez les fichiers à inclure, saisissez un message, puis 'Add + Commit'." + #LF$ + tips$ + "5) " + Chr(149) + " Pour partager en ligne : créez un dépôt distant (GitHub/GitLab…) puis utilisez 'Push'." + #LF$ + #LF$ - tips$ + "4) " + Chr(149) + " Saisissez un message puis cliquez sur 'Add + Commit' (coche 'Pousser après' si besoin)." + #LF$ - tips$ + "5) " + Chr(149) + " Pour changer/recuperer une branche : bouton 'Avancé…'." + #LF$ + #LF$ + Else + ; ---- Dépôt déjà prêt ---- + tips$ + "Étapes :" + #LF$ + tips$ + "1) " + Chr(149) + " (Optionnel) Créez/complétez un '.gitignore' si nécessaire." + #LF$ + tips$ + "2) " + Chr(149) + " Vérifiez l’identité Git locale." + #LF$ + If name$ = "" Or mail$ = "" + tips$ + " → Identité : INCOMPLÈTE (utilisez 'Configurer identité…')." + #LF$ + Else + tips$ + " → Identité : " + name$ + " <" + mail$ + ">" + #LF$ + EndIf + tips$ + "3) " + Chr(149) + " Cochez les fichiers à inclure au prochain commit (bouton 'Diff…' pour voir les détails)." + #LF$ + If hasChanges + tips$ + " → Des modifications sont détectées ci-dessus." + #LF$ + Else + tips$ + " → Aucune modification détectée pour l’instant." + #LF$ + EndIf + tips$ + "4) " + Chr(149) + " Saisissez un message, cliquez 'Add + Commit' (et cochez 'Pousser après' si vous voulez envoyer au serveur)." + #LF$ + tips$ + "5) " + Chr(149) + " Pour changer/restaurer une branche : 'Avancé…'." + #LF$ + #LF$ + EndIf tips$ + "Infos :" + #LF$ tips$ + "• Remote : " + remote$ + " • Branche : " + branch$ + #LF$ - tips$ + "• Cliquez sur 'Diff…' pour voir le détail d’un fichier sélectionné." + #LF$ + tips$ + "• 'Diff…' affiche le détail d’un fichier sélectionné." + #LF$ + #LF$ + + ; Rappel pédagogique (commit vs push) + tips$ + "Rappel : différence entre Commit et Push" + #LF$ + tips$ + "• Commit : enregistre localement un instantané de vos fichiers (dans l’historique du dépôt sur votre machine)." + #LF$ + tips$ + "• Push : envoie vos commits locaux vers un serveur distant (GitHub, GitLab, etc.)." + #LF$ + tips$ + "→ On peut faire des commits hors-ligne ; le push nécessite un dépôt distant configuré (ex. 'origin') et une branche (ex. 'main')." + #LF$ SetGadgetText(#GGuide, tips$) + + If #EnableDebug + Debug "[UpdateGuide] repoReady=" + Str(repoReady) + " changes=" + Str(hasChanges) + EndIf + ProcedureReturn 1 EndProcedure + ; ====== UI principale ====== ; Gadgets IDs (inclut les NOUVEAUX boutons) #GWindow = 1 @@ -840,7 +905,7 @@ Procedure.i OpenGUI(initialDir$, prefsPath$) ; Panneau Guide EditorGadget(#GGuide, 10, 490, 800, 140) - DisableGadget(#GGuide, 1) + ;DisableGadget(#GGuide, 1) ; Infobulles GadgetToolTip(#GListStatus, "Cochez pour inclure un fichier dans le prochain commit. Double-cliquez pour sélectionner, bouton 'Diff…' pour le détail.") @@ -1208,8 +1273,8 @@ Else EndIf ; IDE Options = PureBasic 6.21 (Windows - x64) -; CursorPosition = 1010 -; FirstLine = 969 +; CursorPosition = 835 +; FirstLine = 794 ; Folding = ------ ; EnableXP ; DPIAware diff --git a/PureBasic_Compilation1.exe b/PureBasic_Compilation1.exe index bfe5a97..4a2b2dc 100644 Binary files a/PureBasic_Compilation1.exe and b/PureBasic_Compilation1.exe differ