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
- Setup (once): clone,
cd mini-git, scripts/init.sh, skim README.md + minigit/errors.py
- Branch:
git checkout main && git pull && git checkout -b week1/m1-object-store-skeleton
- Open
minigit/objects.py, keep docstring, add imports: zlib, Path, ObjectNotFoundError
__init__(self, repo_path=".") -> self.root, self.objects_dir, self._fake_store dict; no mkdir yet
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
write_object -> hash it, store in dict, return hash; writing twice must not error
read_object -> miss = raise ObjectNotFoundError(hash); hit = return (type, data)
- round-trip rule:
read_object(write_object(b"hi", "blob")) == ("blob", b"hi")
- CLI:
register_subcommands(subparsers) -> minigit hash-object <path>, minigit cat-file <hash>
- Wire into
minigit/cli.py - one import + one line in _register_commands; expect a small conflict
- Tests
tests/test_objects.py - round-trip, identical -> same hash, different -> different, idempotent write, unknown hash raises
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
Owner: @mahis1067
Module: 1 - Object storage
File you own:
minigit/objects.pyWeek: 1 of 10 - Contract & Skeletons
What "skeleton week" means
Interface contract - exact signatures, do not change alone
obj_typeis one of"blob","tree","commit"(type, content)tuple (read path)Steps
cd mini-git,scripts/init.sh, skimREADME.md+minigit/errors.pygit checkout main && git pull && git checkout -b week1/m1-object-store-skeletonminigit/objects.py, keep docstring, add imports:zlib,Path,ObjectNotFoundError__init__(self, repo_path=".")->self.root,self.objects_dir,self._fake_storedict; nomkdiryethash_object->return f"{zlib.crc32(obj_type.encode() + data):040x}"# placeholder - real SHA-1 of "<type> <len>\0<content>" lands Week 2write_object-> hash it, store in dict, return hash; writing twice must not errorread_object-> miss =raise ObjectNotFoundError(hash); hit = return(type, data)read_object(write_object(b"hi", "blob")) == ("blob", b"hi")register_subcommands(subparsers)->minigit hash-object <path>,minigit cat-file <hash>minigit/cli.py- one import + one line in_register_commands; expect a small conflicttests/test_objects.py- round-trip, identical -> same hash, different -> different, idempotent write, unknown hash raisesscripts/quality-check.shgreen -> commit, push, PR intomain, fill checklist, request reviewTeam checkpoint (all four, end of week)
Done when