@@ -15,20 +15,20 @@ def get_current_version():
1515 if not init_file .exists ():
1616 print ("Error: clipse_gui/__init__.py not found" )
1717 sys .exit (1 )
18-
18+
1919 content = init_file .read_text ()
2020 match = re .search (r'__version__ = "([^"]+)"' , content )
2121 if not match :
2222 print ("Error: Could not find version in __init__.py" )
2323 sys .exit (1 )
24-
24+
2525 return match .group (1 )
2626
2727
2828def parse_version (version_str ):
2929 """Parse version string into major, minor, patch components"""
3030 try :
31- parts = version_str .split ('.' )
31+ parts = version_str .split ("." )
3232 if len (parts ) != 3 :
3333 raise ValueError ("Version must have 3 parts" )
3434 return [int (part ) for part in parts ]
@@ -40,7 +40,7 @@ def parse_version(version_str):
4040def bump_version (current_version , bump_type ):
4141 """Bump version based on type (major, minor, patch)"""
4242 major , minor , patch = parse_version (current_version )
43-
43+
4444 if bump_type == "major" :
4545 major += 1
4646 minor = 0
@@ -53,21 +53,19 @@ def bump_version(current_version, bump_type):
5353 else :
5454 print (f"Error: Invalid bump type '{ bump_type } '. Use major, minor, or patch" )
5555 sys .exit (1 )
56-
56+
5757 return f"{ major } .{ minor } .{ patch } "
5858
5959
6060def update_init_file (new_version ):
6161 """Update version in __init__.py"""
6262 init_file = Path ("clipse_gui/__init__.py" )
6363 content = init_file .read_text ()
64-
64+
6565 new_content = re .sub (
66- r'__version__ = "[^"]+"' ,
67- f'__version__ = "{ new_version } "' ,
68- content
66+ r'__version__ = "[^"]+"' , f'__version__ = "{ new_version } "' , content
6967 )
70-
68+
7169 init_file .write_text (new_content )
7270 print (f"Updated clipse_gui/__init__.py to version { new_version } " )
7371
@@ -78,15 +76,11 @@ def update_makefile(new_version):
7876 if not makefile .exists ():
7977 print ("Warning: Makefile not found, skipping desktop entry version update" )
8078 return
81-
79+
8280 content = makefile .read_text ()
83-
84- new_content = re .sub (
85- r'"Version=[^"]*"' ,
86- f'"Version={ new_version } "' ,
87- content
88- )
89-
81+
82+ new_content = re .sub (r'"Version=[^"]*"' , f'"Version={ new_version } "' , content )
83+
9084 makefile .write_text (new_content )
9185 print (f"Updated Makefile desktop entry to version { new_version } " )
9286
@@ -96,19 +90,19 @@ def interactive_bump():
9690 current_version = get_current_version ()
9791 print (f"Current version: { current_version } " )
9892 print ()
99-
93+
10094 # Show what each bump type would result in
10195 major_version = bump_version (current_version , "major" )
10296 minor_version = bump_version (current_version , "minor" )
10397 patch_version = bump_version (current_version , "patch" )
104-
98+
10599 print ("Select bump type:" )
106100 print (f"1. Major: { current_version } → { major_version } " )
107101 print (f"2. Minor: { current_version } → { minor_version } " )
108102 print (f"3. Patch: { current_version } → { patch_version } " )
109103 print ("4. Cancel" )
110104 print ()
111-
105+
112106 while True :
113107 try :
114108 choice = input ("Enter choice (1-4): " ).strip ()
@@ -137,28 +131,28 @@ def main():
137131 print ("Usage: python bump_version.py [major|minor|patch]" )
138132 print ("Or run without arguments for interactive mode" )
139133 sys .exit (1 )
140-
134+
141135 current_version = get_current_version ()
142136 new_version = bump_version (current_version , bump_type )
143137 print (f"Bumping { bump_type } version: { current_version } → { new_version } " )
144138 else :
145139 # Interactive mode
146140 bump_type , new_version = interactive_bump ()
147141 print (f"Bumping { bump_type } version to { new_version } " )
148-
142+
149143 # Confirm the change
150144 confirm = input ("Proceed with version bump? (y/N): " ).strip ().lower ()
151145 if confirm not in ["y" , "yes" ]:
152146 print ("Cancelled" )
153147 sys .exit (0 )
154-
148+
155149 # Update files
156150 update_init_file (new_version )
157151 update_makefile (new_version )
158-
152+
159153 print (f"Version successfully bumped to { new_version } " )
160154 print ("Don't forget to commit the changes!" )
161155
162156
163157if __name__ == "__main__" :
164- main ()
158+ main ()
0 commit comments