Autocommit
This commit is contained in:
parent
5b195acca8
commit
f3c89ecbc0
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.svn
|
||||||
@ -26,7 +26,7 @@ class GitSvnSyncApp:
|
|||||||
self.file_handler.setLevel(logging.INFO)
|
self.file_handler.setLevel(logging.INFO)
|
||||||
self.file_handler.setFormatter(self.log_formatter)
|
self.file_handler.setFormatter(self.log_formatter)
|
||||||
self.logger.addHandler(self.file_handler)
|
self.logger.addHandler(self.file_handler)
|
||||||
self.log_text = scrolledtext.ScrolledText(master, height=10, width=80)
|
self.log_text = scrolledtext.ScrolledText(master, height=10, width=100, font=("Courier New", 8, "normal"))
|
||||||
self.log_text.pack(pady=10)
|
self.log_text.pack(pady=10)
|
||||||
self.log_text.config(state=tk.DISABLED)
|
self.log_text.config(state=tk.DISABLED)
|
||||||
self.text_handler = TextHandler(self.log_text)
|
self.text_handler = TextHandler(self.log_text)
|
||||||
@ -95,6 +95,13 @@ class GitSvnSyncApp:
|
|||||||
self.bundle_updated_name_entry = ttk.Entry(self.settings_frame, width=60)
|
self.bundle_updated_name_entry = ttk.Entry(self.settings_frame, width=60)
|
||||||
self.bundle_updated_name_entry.grid(row=3, column=1, sticky=tk.W)
|
self.bundle_updated_name_entry.grid(row=3, column=1, sticky=tk.W)
|
||||||
|
|
||||||
|
# Aggiungi questa variabile all'inizio della classe GitSvnSyncApp
|
||||||
|
self.autocommit_var = tk.BooleanVar()
|
||||||
|
|
||||||
|
# Aggiungi questo checkbox nell'interfaccia grafica (nel metodo __init__)
|
||||||
|
self.autocommit_checkbox = ttk.Checkbutton(master, text="Autocommit", variable=self.autocommit_var)
|
||||||
|
self.autocommit_checkbox.pack(pady=5)
|
||||||
|
|
||||||
# Pulsanti
|
# Pulsanti
|
||||||
self.prepare_svn_button = ttk.Button(master, text="Prepare SVN for Git", command=self.prepare_svn_for_git)
|
self.prepare_svn_button = ttk.Button(master, text="Prepare SVN for Git", command=self.prepare_svn_for_git)
|
||||||
self.prepare_svn_button.pack(pady=5)
|
self.prepare_svn_button.pack(pady=5)
|
||||||
@ -259,10 +266,45 @@ class GitSvnSyncApp:
|
|||||||
messagebox.showerror("Error", f"Il percorso SVN '{svn_path}' non esiste.")
|
messagebox.showerror("Error", f"Il percorso SVN '{svn_path}' non esiste.")
|
||||||
return
|
return
|
||||||
|
|
||||||
bundle_path = os.path.join(self.usb_path_entry.get(), self.bundle_name_entry.get()).replace("\\", "/") # Modifica qui
|
# Verifica se ci sono commit nel repository Git
|
||||||
|
try:
|
||||||
|
command = ["git", "log", "--oneline"]
|
||||||
|
result = self.log_and_execute(command, check=False) # Non generare un errore se non ci sono commit
|
||||||
|
if not result.stdout:
|
||||||
|
self.logger.error("Errore: Il repository Git è vuoto. Assicurati di aver aggiunto e committato i file.")
|
||||||
|
messagebox.showerror("Error", "Errore: Il repository Git è vuoto. Assicurati di aver aggiunto e committato i file.")
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Errore durante la verifica dei commit: {e}")
|
||||||
|
messagebox.showerror("Error", f"Errore durante la verifica dei commit: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Autocommit
|
||||||
|
if self.autocommit_var.get():
|
||||||
|
self.logger.info("Autocommit abilitato.")
|
||||||
|
try:
|
||||||
|
# Verifica se ci sono modifiche
|
||||||
|
command = ["git", "status", "-s"]
|
||||||
|
result = self.log_and_execute(command, check=False)
|
||||||
|
if result.stdout:
|
||||||
|
self.logger.info("Rilevate modifiche nel repository Git. Esecuzione autocommit...")
|
||||||
|
# Esegui git add .
|
||||||
|
command = ["git", "add", "."]
|
||||||
|
self.log_and_execute(command)
|
||||||
|
# Esegui git commit -m "Autocommit"
|
||||||
|
command = ["git", "commit", "-m", "Autocommit"]
|
||||||
|
self.log_and_execute(command)
|
||||||
|
self.logger.info("Autocommit eseguito con successo.")
|
||||||
|
else:
|
||||||
|
self.logger.info("Nessuna modifica rilevata nel repository Git. Autocommit non necessario.")
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Errore durante l'autocommit: {e}")
|
||||||
|
messagebox.showerror("Error", f"Errore durante l'autocommit: {e}")
|
||||||
|
|
||||||
|
bundle_path = os.path.join(self.usb_path_entry.get(), self.bundle_name_entry.get()).replace("\\", "/")
|
||||||
command = ["git", "bundle", "create", bundle_path, "--all"]
|
command = ["git", "bundle", "create", bundle_path, "--all"]
|
||||||
try:
|
try:
|
||||||
self.log_and_execute(command)
|
result = self.log_and_execute(command)
|
||||||
self.logger.info("Bundle Git creato con successo.")
|
self.logger.info("Bundle Git creato con successo.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f"Errore durante la creazione del bundle: {e}")
|
self.logger.error(f"Errore durante la creazione del bundle: {e}")
|
||||||
@ -272,9 +314,14 @@ class GitSvnSyncApp:
|
|||||||
"""Recupera le modifiche dal bundle nel repository Git locale."""
|
"""Recupera le modifiche dal bundle nel repository Git locale."""
|
||||||
self.save_profile_settings() # Salva le impostazioni del profilo corrente
|
self.save_profile_settings() # Salva le impostazioni del profilo corrente
|
||||||
self.logger.info("Recupero delle modifiche dal bundle Git...")
|
self.logger.info("Recupero delle modifiche dal bundle Git...")
|
||||||
bundle_path = os.path.join(self.usb_path_entry.get(), self.bundle_updated_name_entry.get())
|
bundle_path = os.path.join(self.usb_path_entry.get(), self.bundle_updated_name_entry.get()).replace("\\", "/")
|
||||||
|
# Verifica che il file bundle esista
|
||||||
|
if not os.path.exists(bundle_path):
|
||||||
|
self.logger.error(f"Il file bundle '{bundle_path}' non esiste.")
|
||||||
|
messagebox.showerror("Error", f"Il file bundle '{bundle_path}' non esiste.")
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
fetch_command = ["git", "fetch", bundle_path, "--all"]
|
fetch_command = ["git", "fetch", bundle_path] # Rimuovi --all
|
||||||
self.log_and_execute(fetch_command)
|
self.log_and_execute(fetch_command)
|
||||||
merge_command = ["git", "merge", "FETCH_HEAD"]
|
merge_command = ["git", "merge", "FETCH_HEAD"]
|
||||||
self.log_and_execute(merge_command)
|
self.log_and_execute(merge_command)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user