Skip to content

Week 1 - M1: ObjectStore skeleton + CLI stubs #2

Description

@aman-a-shah

Owner: @mahis1067
Module: 1 - Object storage
File you own: minigit/objects.py
Week: 1 of 10 - Contract & Skeletons

What "skeleton week" means

  • no real hashing, no zlib, no disk writes yet -> that's Week 2
  • goal: every method exists, exact signature, returns a fake but correctly-shaped value
  • so Modules 2/3/4 can import your class and start building against it today

Interface contract - exact signatures, do not change alone

class ObjectStore:
    def hash_object(self, data: bytes, obj_type: str) -> str: ...
    def write_object(self, data: bytes, obj_type: str) -> str: ...
    def read_object(self, hash: str) -> tuple[str, bytes]: ...
  • obj_type is one of "blob", "tree", "commit"
  • returns hex hash string (write path) or (type, content) tuple (read path)

Steps

  1. Setup (once): clone, cd mini-git, scripts/init.sh, skim README.md + minigit/errors.py
  2. Branch: git checkout main && git pull && git checkout -b week1/m1-object-store-skeleton
  3. Open minigit/objects.py, keep docstring, add imports: zlib, Path, ObjectNotFoundError
  4. __init__(self, repo_path=".") -> self.root, self.objects_dir, self._fake_store dict; no mkdir yet
  5. hash_object -> return f"{zlib.crc32(obj_type.encode() + data):040x}"
    • # placeholder - real SHA-1 of "<type> <len>\0<content>" lands Week 2
    • rules already holding: same bytes -> same hash, different bytes -> different hash, no disk write
  6. write_object -> hash it, store in dict, return hash; writing twice must not error
  7. read_object -> miss = raise ObjectNotFoundError(hash); hit = return (type, data)
    • round-trip rule: read_object(write_object(b"hi", "blob")) == ("blob", b"hi")
  8. CLI: register_subcommands(subparsers) -> minigit hash-object <path>, minigit cat-file <hash>
  9. Wire into minigit/cli.py - one import + one line in _register_commands; expect a small conflict
  10. Tests tests/test_objects.py - round-trip, identical -> same hash, different -> different, idempotent write, unknown hash raises
  11. scripts/quality-check.sh green -> commit, push, PR into main, fill checklist, request review

Team checkpoint (all four, end of week)

  • contract signatures confirmed in the group chat before anyone merges
  • everyone imports everyone else's class and calls one method -> shaped fake result back
  • you are the only module with no dependencies -> your PR should land first

Done when

  • all 3 methods, exact signatures
  • round-trip works
  • both CLI commands run
  • tests pass
  • quality-check green
  • PR open + reviewed

Metadata

Metadata

Assignees

Labels

module-1Object storageweek-1Week 1 - contract and skeletons

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions