Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/publish_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def handle_publications(manifest_data: List[Dict[str, Any]]) -> bool:
dataset["history"][i] = entry
finalize_manifest(
manifest_data,
f"ci: Publish {dataset['fileName']} v{entry['version']}",
f"ci: Publish {dataset['fileName']} {entry['version']}",
)
return True # Process only one publication per run

Expand Down
33 changes: 2 additions & 31 deletions src/datamanager/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from rich.console import Console
from rich.table import Table

from typing import Callable, Optional, cast, Any
from typing import Callable, Optional, Any

from datamanager.config import settings
from datamanager import core, manifest
Expand All @@ -27,35 +27,6 @@
)


# Git helpers
def _stage_all() -> None:
"""Stage every working-tree change."""
subprocess.run(["git", "add", "-A"], check=True)


def _build_detached_commit(message: str) -> str:
"""
Create a commit object from the **current index** without
moving HEAD. Returns the full commit SHA.
"""
tree = subprocess.check_output(["git", "write-tree"], text=True).strip()
parent = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
sha = subprocess.check_output(
["git", "commit-tree", tree, "-p", parent, "-m", message],
text=True,
).strip()
return sha


# Prompt helpers
def _ask_text(ctx: typer.Context, prompt: str, default: str) -> str:
if ctx.obj.get("no_prompt"): # ← global flag
console.print(f"[cyan]--yes[/] given – using default message: '{default}'")
return default
result: Optional[str] = questionary.text(prompt, default=default).ask()
return cast(str, result)


def _ask_confirm(ctx: typer.Context, prompt: str, default: bool = False) -> bool:
if ctx.obj.get("no_prompt"):
return True
Expand Down Expand Up @@ -321,7 +292,7 @@ def _run_prepare_logic(ctx: typer.Context, name: str, file: Path) -> None:
manifest.add_history_entry(name, new_entry)

else:
# --- This is for CREATE
# --- This is for CREATE ---
new_dataset_obj = {
"fileName": name,
"latestVersion": "v1",
Expand Down
8 changes: 4 additions & 4 deletions src/datamanager/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def add_history_entry(name: str, new_entry: dict[str, Any]) -> None:
Adds a new version entry to the beginning of a dataset's history.

This function is used to add the temporary placeholder before the final
commit hash is known.
commit hash is known. It only works for existing datasets. For creating
new datasets, use add_new_dataset() instead.

Args:
name: The 'fileName' of the dataset to update.
Expand All @@ -111,9 +112,8 @@ def add_history_entry(name: str, new_entry: dict[str, Any]) -> None:
break

if not dataset_found:
# This would be for creating a brand new dataset entry
# For now, we assume we only update existing ones.
# A 'datamanager create' command could use this logic.
# We only update existing datasets. For creating new datasets,
# use add_new_dataset() instead.
console.print(f"Dataset '{name}' not found. Cannot add history.")
return

Expand Down