Chore: Stop tracking files based on .gitignore update.
Summary: - Rule "*.ini" untracked 1 file(s). - Rule "*.log" untracked 1 file(s). - Rule "_build/" untracked 15 file(s). - Rule "_dist/" untracked 946 file(s).
This commit is contained in:
parent
4b74cfbe27
commit
e3bf97eeb5
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,5 +1,7 @@
|
|||||||
.svn
|
.svn/
|
||||||
.log
|
*.log
|
||||||
dist
|
dist/
|
||||||
build
|
build/
|
||||||
.ini
|
_dist/
|
||||||
|
_build/
|
||||||
|
*.ini
|
||||||
@ -976,41 +976,73 @@ class GitCommands:
|
|||||||
def remove_from_tracking(self, working_directory, files_to_untrack):
|
def remove_from_tracking(self, working_directory, files_to_untrack):
|
||||||
"""
|
"""
|
||||||
Removes specified files/directories from Git tracking (index)
|
Removes specified files/directories from Git tracking (index)
|
||||||
without deleting them from the working directory.
|
without deleting them from the working directory. Processes files in batches
|
||||||
|
to avoid command line length limits.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
working_directory (str): Path to the Git repository.
|
working_directory (str): Path to the Git repository.
|
||||||
files_to_untrack (list): List of relative paths to untrack.
|
files_to_untrack (list): List of relative paths to untrack.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if the command executed successfully (even if nothing was removed).
|
bool: True if all batches executed successfully.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
GitCommandError: If the git command fails.
|
GitCommandError: If any git rm batch command fails.
|
||||||
ValueError: If the list of files is empty.
|
ValueError: If the list of files is empty.
|
||||||
"""
|
"""
|
||||||
if not files_to_untrack:
|
if not files_to_untrack:
|
||||||
raise ValueError("File list cannot be empty for remove_from_tracking.")
|
# Non è un errore se la lista è vuota, semplicemente non c'è nulla da fare.
|
||||||
|
self.logger.debug("No files provided to remove_from_tracking.")
|
||||||
|
return True # Considera successo non fare nulla
|
||||||
|
|
||||||
self.logger.info(f"Removing {len(files_to_untrack)} items from Git tracking...")
|
self.logger.info(f"Removing {len(files_to_untrack)} items from Git tracking in batches...")
|
||||||
self.logger.debug(f"Items to untrack: {files_to_untrack}")
|
|
||||||
|
|
||||||
# Base command
|
# --- MODIFICA: Logica Batch ---
|
||||||
command = ["git", "rm", "--cached", "--"] # "--" separates options from paths
|
batch_size = 100 # Processa N file alla volta (regola se necessario)
|
||||||
# Add all file paths to the command
|
all_batches_succeeded = True
|
||||||
command.extend(files_to_untrack)
|
|
||||||
|
for i in range(0, len(files_to_untrack), batch_size):
|
||||||
|
batch = files_to_untrack[i : i + batch_size]
|
||||||
|
if not batch: # Salta batch vuoti (non dovrebbe succedere con range)
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.logger.info(f"Processing untrack batch {i // batch_size + 1}: {len(batch)} items...")
|
||||||
|
self.logger.debug(f"Batch items: {batch}")
|
||||||
|
|
||||||
|
# Costruisci il comando per questo batch
|
||||||
|
command = ["git", "rm", "--cached", "-r", "--ignore-unmatch", "--"] # Aggiunto -r e --ignore-unmatch
|
||||||
|
# -r: Necessario se alcuni 'file' sono in realtà directory (come _build/, _dist/)
|
||||||
|
# --ignore-unmatch: Evita errori se un file è già stato rimosso o non trovato per qualche motivo strano
|
||||||
|
command.extend(batch)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# check=True ensures an error is raised if `git rm` fails
|
# Esegui il comando per il batch corrente
|
||||||
self.log_and_execute(command, working_directory, check=True)
|
# Logga l'output a DEBUG per non inondare il log INFO
|
||||||
self.logger.info("Successfully removed items from tracking index.")
|
self.log_and_execute(command, working_directory, check=True, log_output_level=logging.DEBUG)
|
||||||
return True
|
self.logger.info(f"Batch {i // batch_size + 1} untracked successfully.")
|
||||||
|
|
||||||
except (GitCommandError, ValueError) as e:
|
except (GitCommandError, ValueError) as e:
|
||||||
self.logger.error(f"Failed to remove items from tracking: {e}")
|
self.logger.error(f"Failed to process untrack batch {i // batch_size + 1}: {e}")
|
||||||
raise # Re-raise original error
|
# Puoi decidere se interrompere o continuare con gli altri batch.
|
||||||
|
# Interrompere è generalmente più sicuro.
|
||||||
|
all_batches_succeeded = False
|
||||||
|
raise GitCommandError(f"Failed untracking batch {i // batch_size + 1}. Error: {e}", command=command, stderr=getattr(e, 'stderr', None)) from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.exception(f"Unexpected error removing from tracking: {e}")
|
self.logger.exception(f"Unexpected error processing untrack batch {i // batch_size + 1}: {e}")
|
||||||
raise GitCommandError(f"Unexpected untrack error: {e}", command=command) from e
|
all_batches_succeeded = False
|
||||||
|
raise GitCommandError(f"Unexpected untrack batch error: {e}", command=command) from e
|
||||||
|
|
||||||
|
# Se arriviamo qui, il batch ha avuto successo
|
||||||
|
|
||||||
|
# Ritorna True solo se TUTTI i batch hanno avuto successo
|
||||||
|
if all_batches_succeeded:
|
||||||
|
self.logger.info("All untracking batches completed successfully.")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
# Questo caso non dovrebbe essere raggiunto se solleviamo eccezioni sopra,
|
||||||
|
# ma lo teniamo per sicurezza.
|
||||||
|
self.logger.error("Untracking process completed with errors in some batches.")
|
||||||
|
return False
|
||||||
|
|
||||||
def get_matching_gitignore_rule(self, working_directory, path_to_check):
|
def get_matching_gitignore_rule(self, working_directory, path_to_check):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user