Files
Orchestrator/privat/NoteGraph/ingestion/integrations/git.py
T
ankn a5f8fb49ab Migrate all repos into monorepo context folders
Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
      Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
      Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)

Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
2026-06-30 20:39:52 +02:00

67 lines
1.9 KiB
Python

"""Git commit operations for auto-committing imported notes.
Stages new markdown files and stub pages, commits with message format:
ingestion: import N notes from [source-type]
Supports --no-commit flag. Handles git failures gracefully.
"""
import logging
import subprocess
from pathlib import Path
logger = logging.getLogger(__name__)
def commit_imported_notes(files: list[Path], source_type: str = "import") -> bool:
"""Stage and commit imported note files.
Args:
files: List of file paths to stage and commit.
source_type: Source description for commit message (e.g., 'batch-import', 'upload', 'nextcloud').
Returns:
True if commit succeeded, False otherwise.
"""
if not files:
logger.debug("No files to commit.")
return False
try:
# Stage files
file_strs = [str(f) for f in files]
subprocess.run(
["git", "add"] + file_strs,
capture_output=True,
text=True,
check=True,
)
# Commit
count = len(files)
message = f"ingestion: import {count} notes from {source_type}"
result = subprocess.run(
["git", "commit", "-m", message],
capture_output=True,
text=True,
)
if result.returncode == 0:
logger.info("Git commit: %s", message)
return True
else:
# Nothing to commit (files already tracked/unchanged)
logger.debug("Git commit returned %d: %s", result.returncode, result.stderr.strip())
return False
except FileNotFoundError:
logger.warning("Git not found in PATH — skipping commit.")
return False
except subprocess.CalledProcessError as e:
logger.warning("Git operation failed: %s", e.stderr.strip() if e.stderr else str(e))
return False
except Exception as e:
logger.warning("Unexpected git error: %s", e)
return False