77PACKAGE_FILE = pathlib .Path ("socketsecurity/__init__.py" )
88VERSION_PATTERN = re .compile (r"__version__\s*=\s*['\"]([^'\"]+)['\"]" )
99
10- def get_hatch_version ():
11- return subprocess .check_output (["hatch" , "version" ], text = True ).strip ()
10+ def get_hatch_version (full = False ):
11+ raw = subprocess .check_output (["hatch" , "version" ], text = True ).strip ()
12+ if full :
13+ return raw
14+ return raw .split (".dev" )[0 ].split ("+" )[0 ] # Just base version
1215
1316def get_current_version ():
1417 content = PACKAGE_FILE .read_text ()
@@ -21,17 +24,18 @@ def update_version(new_version):
2124 PACKAGE_FILE .write_text (new_content )
2225
2326def main ():
24- hatch_version = get_hatch_version ()
27+ full_mode = "--dev" in sys .argv
28+ hatch_version = get_hatch_version (full = full_mode )
2529 current_version = get_current_version ()
2630
2731 if not current_version :
28- print ("❌ Couldn't find __version__ in" , PACKAGE_FILE )
32+ print (f "❌ Couldn't find __version__ in { PACKAGE_FILE } " )
2933 return 1
3034
3135 if hatch_version != current_version :
32- print (f"🔁 Syncing version: { current_version } → { hatch_version } " )
36+ print (f"🔁 Updating version: { current_version } → { hatch_version } " )
3337 update_version (hatch_version )
34- return 1 # Exit 1 so pre-commit fails and shows diff
38+ return 1 if not full_mode else 0 # Fail locally to force re-add, but not in CI
3539
3640 print (f"✅ Version is in sync: { hatch_version } " )
3741 return 0
0 commit comments