Commit f63be7afff9431bd422ea2aff6d50fd845f17f86
1 parent
0a1d6678
Continue release manager development
Showing
1 changed file
with
344 additions
and
221 deletions
dev/release.py
| ... | ... | @@ -20,6 +20,179 @@ |
| 20 | 20 | # ========================================================================== |
| 21 | 21 | import os |
| 22 | 22 | import sys |
| 23 | +import commands | |
| 24 | + | |
| 25 | + | |
| 26 | +# ================= # | |
| 27 | +# Confirm something # | |
| 28 | +# ================= # | |
| 29 | +def confirm(text): | |
| 30 | + """ | |
| 31 | + Confirm something | |
| 32 | + | |
| 33 | + Parameters | |
| 34 | + ---------- | |
| 35 | + text : str | |
| 36 | + Thing to confirm | |
| 37 | + | |
| 38 | + Returns | |
| 39 | + ------- | |
| 40 | + flag : bool | |
| 41 | + True if something is confirmed | |
| 42 | + """ | |
| 43 | + # Confirmation loop | |
| 44 | + waiting = True | |
| 45 | + while waiting: | |
| 46 | + confirmation = str(raw_input(text+' (y/n): ')) | |
| 47 | + if confirmation == 'q': | |
| 48 | + sys.exit() | |
| 49 | + elif confirmation == 'y': | |
| 50 | + flag = True | |
| 51 | + waiting = False | |
| 52 | + elif confirmation == 'n': | |
| 53 | + flag = False | |
| 54 | + waiting = False | |
| 55 | + | |
| 56 | + # Return confirmation flag | |
| 57 | + return flag | |
| 58 | + | |
| 59 | + | |
| 60 | +# ============== # | |
| 61 | +# Commit changes # | |
| 62 | +# ============== # | |
| 63 | +def commit(message): | |
| 64 | + """ | |
| 65 | + Commit changes into git repo | |
| 66 | + | |
| 67 | + Parameters | |
| 68 | + ---------- | |
| 69 | + message : str | |
| 70 | + Commit message | |
| 71 | + """ | |
| 72 | + # Show changes | |
| 73 | + print("The following files have been changed:") | |
| 74 | + os.system('git status -s') | |
| 75 | + | |
| 76 | + # Ask again whether the changes should be committed | |
| 77 | + if confirm("Commit all changes?"): | |
| 78 | + | |
| 79 | + # Optionally enter a commit message | |
| 80 | + if len(message) == 0: | |
| 81 | + message = str(raw_input("Please enter a commit message: ")) | |
| 82 | + | |
| 83 | + # Stage all files | |
| 84 | + os.system('git add -u') | |
| 85 | + | |
| 86 | + # Commit all changes | |
| 87 | + os.system('git commit -m "%s"' % message) | |
| 88 | + | |
| 89 | + # Return | |
| 90 | + return | |
| 91 | + | |
| 92 | + | |
| 93 | +# ========================== # | |
| 94 | +# Check if git branch exists # | |
| 95 | +# ========================== # | |
| 96 | +def git_branch_exists(branch): | |
| 97 | + """ | |
| 98 | + Check if git branch exists | |
| 99 | + | |
| 100 | + Parameters | |
| 101 | + ---------- | |
| 102 | + branch : str | |
| 103 | + Branch name | |
| 104 | + | |
| 105 | + Returns | |
| 106 | + ------- | |
| 107 | + exists : bool | |
| 108 | + True if git branch exists | |
| 109 | + """ | |
| 110 | + # Check if git branch exists | |
| 111 | + rc = os.system('git rev-parse --verify %s >/dev/null 2>&1' % branch) | |
| 112 | + | |
| 113 | + # Set exists flag | |
| 114 | + if rc == 0: | |
| 115 | + exists = True | |
| 116 | + else: | |
| 117 | + exists = False | |
| 118 | + | |
| 119 | + # Return flag | |
| 120 | + return exists | |
| 121 | + | |
| 122 | + | |
| 123 | +# ================= # | |
| 124 | +# Create git branch # | |
| 125 | +# ================= # | |
| 126 | +def create_git_branch(branch): | |
| 127 | + """ | |
| 128 | + Create a git branch | |
| 129 | + | |
| 130 | + Parameters | |
| 131 | + ---------- | |
| 132 | + branch : str | |
| 133 | + Branch name | |
| 134 | + """ | |
| 135 | + # If branch exists already then ask whether it should be deleted | |
| 136 | + if git_branch_exists(branch): | |
| 137 | + if confirm("Git branch '%s' exists already, do you want to delete " | |
| 138 | + "it?" % branch): | |
| 139 | + os.system('git branch -D %s' % branch) | |
| 140 | + | |
| 141 | + # If branch exists already then switch to the new branch, otherwise create | |
| 142 | + # new branch and switch to it | |
| 143 | + if git_branch_exists(branch): | |
| 144 | + os.system('git checkout %s' % branch) | |
| 145 | + else: | |
| 146 | + print("Created new branch '%s'" % branch) | |
| 147 | + os.system('git checkout -b %s' % branch) | |
| 148 | + | |
| 149 | + # Return | |
| 150 | + return | |
| 151 | + | |
| 152 | + | |
| 153 | +# ======================================= # | |
| 154 | +# Check whether version string is correct # | |
| 155 | +# ======================================= # | |
| 156 | +def check_version(version): | |
| 157 | + """ | |
| 158 | + Check whether version string is correct | |
| 159 | + | |
| 160 | + Parameters | |
| 161 | + ---------- | |
| 162 | + version : str | |
| 163 | + Version number | |
| 164 | + | |
| 165 | + Returns | |
| 166 | + ------- | |
| 167 | + check : bool | |
| 168 | + True if version string is correct | |
| 169 | + """ | |
| 170 | + # Initialise check with False | |
| 171 | + check = False | |
| 172 | + | |
| 173 | + # Split version string | |
| 174 | + split = version.split('.') | |
| 175 | + | |
| 176 | + # If there are three elements or four elements we may have a valid version | |
| 177 | + # string | |
| 178 | + if len(split) == 3 or len(split) == 4: | |
| 179 | + | |
| 180 | + # If the three first elements are integers we may have a valid version | |
| 181 | + # string | |
| 182 | + if split[0].isdigit() and split[1].isdigit() and split[2].isdigit(): | |
| 183 | + | |
| 184 | + # If we have three elements the version is valid and we are done | |
| 185 | + if len(split) == 3: | |
| 186 | + check = True | |
| 187 | + | |
| 188 | + # Otherwise check if the 4th element is of format devn, where n | |
| 189 | + # is an integer number | |
| 190 | + elif split[3][0:3] == 'dev': | |
| 191 | + if split[3][3:].isdigit(): | |
| 192 | + check = True | |
| 193 | + | |
| 194 | + # Return check | |
| 195 | + return check | |
| 23 | 196 | |
| 24 | 197 | |
| 25 | 198 | # ========================== # |
| ... | ... | @@ -94,78 +267,6 @@ def get_libtool_version(): |
| 94 | 267 | return version |
| 95 | 268 | |
| 96 | 269 | |
| 97 | -# ============================== # | |
| 98 | -# Set version number in one file # | |
| 99 | -# ============================== # | |
| 100 | -def set_version(filename, version, current): | |
| 101 | - """ | |
| 102 | - Set version number | |
| 103 | - | |
| 104 | - Parameters | |
| 105 | - ---------- | |
| 106 | - filename : str | |
| 107 | - File name | |
| 108 | - version : str | |
| 109 | - Version number | |
| 110 | - current : str | |
| 111 | - Current version number | |
| 112 | - """ | |
| 113 | - # Open file in read mode | |
| 114 | - f = open(filename, 'r') | |
| 115 | - | |
| 116 | - # Read file content | |
| 117 | - content = f.read() | |
| 118 | - | |
| 119 | - # Close file | |
| 120 | - f.close() | |
| 121 | - | |
| 122 | - # Replace version number | |
| 123 | - new_content = content.replace(current, version) | |
| 124 | - | |
| 125 | - # Open file in write mode | |
| 126 | - f = open(filename, 'w') | |
| 127 | - | |
| 128 | - # Write file content | |
| 129 | - f.write(new_content) | |
| 130 | - | |
| 131 | - # Close file | |
| 132 | - f.close() | |
| 133 | - | |
| 134 | - # Return | |
| 135 | - return | |
| 136 | - | |
| 137 | - | |
| 138 | -# =============================== # | |
| 139 | -# Set version number in all files # | |
| 140 | -# =============================== # | |
| 141 | -def set_versions(version, current): | |
| 142 | - """ | |
| 143 | - Set version numbers in all files | |
| 144 | - | |
| 145 | - Parameters | |
| 146 | - ---------- | |
| 147 | - version : str | |
| 148 | - Version number | |
| 149 | - current : str | |
| 150 | - Current version number | |
| 151 | - """ | |
| 152 | - # List of all relevant files, including their access paths from the | |
| 153 | - # source directory | |
| 154 | - filenames = ['configure.ac', | |
| 155 | - 'gammalib.pc.in', | |
| 156 | - 'README.md', | |
| 157 | - 'sonar-project.properties', | |
| 158 | - 'doc/Doxyfile', | |
| 159 | - 'doc/source/conf.py'] | |
| 160 | - | |
| 161 | - # Set versions by loop over all files | |
| 162 | - for filename in filenames: | |
| 163 | - set_version(filename, version, current) | |
| 164 | - | |
| 165 | - # Return | |
| 166 | - return | |
| 167 | - | |
| 168 | - | |
| 169 | 270 | # =============================================== # |
| 170 | 271 | # Set libtool version number in configure.ac file # |
| 171 | 272 | # =============================================== # |
| ... | ... | @@ -218,36 +319,51 @@ def set_libtool_version(library=False, added=False, removed=False, changed=False |
| 218 | 319 | version = '%d:%d:%d' % (current, revision, age) |
| 219 | 320 | |
| 220 | 321 | # Set libtool version number |
| 221 | - set_version('configure.ac', version, old) | |
| 322 | + set_version_in_file('configure.ac', version, old) | |
| 222 | 323 | |
| 223 | 324 | # Return |
| 224 | 325 | return |
| 225 | 326 | |
| 226 | 327 | |
| 227 | -# ===================================================== # | |
| 228 | -# Set special version number in doc/source/conf.py file # | |
| 229 | -# ===================================================== # | |
| 230 | -def set_special_doc_source_conf(version, current): | |
| 328 | +# ============================== # | |
| 329 | +# Set version number in one file # | |
| 330 | +# ============================== # | |
| 331 | +def set_version_in_file(filename, version, current): | |
| 231 | 332 | """ |
| 232 | - Set special version numbers in doc/source/conf.py file | |
| 333 | + Set version number in one file | |
| 334 | + | |
| 335 | + The function replaces all current version numbers in a file by a new | |
| 336 | + version number. | |
| 233 | 337 | |
| 234 | 338 | Parameters |
| 235 | 339 | ---------- |
| 340 | + filename : str | |
| 341 | + File name | |
| 236 | 342 | version : str |
| 237 | - Version number | |
| 343 | + New version number | |
| 238 | 344 | current : str |
| 239 | 345 | Current version number |
| 240 | 346 | """ |
| 241 | - # Generate current version number | |
| 242 | - split = current.split('.') | |
| 243 | - cur = '%s.%s' % (split[0], split[1]) | |
| 347 | + # Open file in read mode | |
| 348 | + f = open(filename, 'r') | |
| 244 | 349 | |
| 245 | - # Generate new version number | |
| 246 | - split = version.split('.') | |
| 247 | - ver = '%s.%s' % (split[0], split[1]) | |
| 350 | + # Read file content | |
| 351 | + content = f.read() | |
| 352 | + | |
| 353 | + # Close file | |
| 354 | + f.close() | |
| 248 | 355 | |
| 249 | - # Set version number | |
| 250 | - set_version('doc/source/conf.py', ver, cur) | |
| 356 | + # Replace version number | |
| 357 | + new_content = content.replace(current, version) | |
| 358 | + | |
| 359 | + # Open file in write mode | |
| 360 | + f = open(filename, 'w') | |
| 361 | + | |
| 362 | + # Write file content | |
| 363 | + f.write(new_content) | |
| 364 | + | |
| 365 | + # Close file | |
| 366 | + f.close() | |
| 251 | 367 | |
| 252 | 368 | # Return |
| 253 | 369 | return |
| ... | ... | @@ -256,8 +372,7 @@ def set_special_doc_source_conf(version, current): |
| 256 | 372 | # ======================= # |
| 257 | 373 | # Set the package version # |
| 258 | 374 | # ======================= # |
| 259 | -def set_package_version(version, library=False, added=False, removed=False, | |
| 260 | - changed=False): | |
| 375 | +def set_package_version(version): | |
| 261 | 376 | """ |
| 262 | 377 | Set the package version |
| 263 | 378 | |
| ... | ... | @@ -266,66 +381,61 @@ def set_package_version(version, library=False, added=False, removed=False, |
| 266 | 381 | version : str |
| 267 | 382 | Version number |
| 268 | 383 | """ |
| 384 | + # List of all files in which the version numbers should be changed. The | |
| 385 | + # file name should include their access paths with respect to the source | |
| 386 | + # directory | |
| 387 | + filenames = ['configure.ac', | |
| 388 | + 'gammalib.pc.in', | |
| 389 | + 'README.md', | |
| 390 | + 'sonar-project.properties', | |
| 391 | + 'doc/Doxyfile', | |
| 392 | + 'doc/source/conf.py'] | |
| 393 | + | |
| 394 | + | |
| 269 | 395 | # Get the current package version |
| 270 | 396 | current = get_current_version() |
| 271 | 397 | |
| 272 | - # Set versions | |
| 273 | - set_versions(version, current) | |
| 398 | + # Set versions by loop over all files | |
| 399 | + for filename in filenames: | |
| 400 | + set_version_in_file(filename, version, current) | |
| 274 | 401 | |
| 275 | - # Set libtool version | |
| 276 | - set_libtool_version(library=library, added=added, removed=removed, | |
| 277 | - changed=changed) | |
| 402 | + # Generate current version number | |
| 403 | + split = current.split('.') | |
| 404 | + cur = '%s.%s' % (split[0], split[1]) | |
| 405 | + | |
| 406 | + # Generate new version number | |
| 407 | + split = version.split('.') | |
| 408 | + ver = '%s.%s' % (split[0], split[1]) | |
| 278 | 409 | |
| 279 | - # Set special version number in doc/source/conf.py file | |
| 280 | - set_special_doc_source_conf(version, current) | |
| 410 | + # Set version number in doc/source/conf.py file | |
| 411 | + set_version_in_file('doc/source/conf.py', ver, cur) | |
| 281 | 412 | |
| 282 | 413 | # Return |
| 283 | 414 | return |
| 284 | 415 | |
| 285 | 416 | |
| 286 | -# ======================================= # | |
| 287 | -# Check whether version string is correct # | |
| 288 | -# ======================================= # | |
| 289 | -def check_version(version): | |
| 417 | +# ============= # | |
| 418 | +# Build tarball # | |
| 419 | +# ============= # | |
| 420 | +def build_tarball(branch, folder): | |
| 290 | 421 | """ |
| 291 | - Check whether version string is correct | |
| 422 | + Build tarball from git branch | |
| 292 | 423 | |
| 293 | 424 | Parameters |
| 294 | 425 | ---------- |
| 295 | - version : str | |
| 296 | - Version number | |
| 297 | - | |
| 298 | - Returns | |
| 299 | - ------- | |
| 300 | - check : bool | |
| 301 | - True if version string is correct | |
| 426 | + branch : str | |
| 427 | + Git branch | |
| 428 | + folder : str | |
| 429 | + Folder name | |
| 302 | 430 | """ |
| 303 | - # Initialise check with False | |
| 304 | - check = False | |
| 305 | - | |
| 306 | - # Split version string | |
| 307 | - split = version.split('.') | |
| 308 | - | |
| 309 | - # If there are three elements or four elements we may have a valid version | |
| 310 | - # string | |
| 311 | - if len(split) == 3 or len(split) == 4: | |
| 312 | - | |
| 313 | - # If the three first elements are integers we may have a valid version | |
| 314 | - # string | |
| 315 | - if split[0].isdigit() and split[1].isdigit() and split[2].isdigit(): | |
| 316 | - | |
| 317 | - # If we have three elements the version is valid and we are done | |
| 318 | - if len(split) == 3: | |
| 319 | - check = True | |
| 320 | - | |
| 321 | - # Otherwise check if the 4th element is of format devn, where n | |
| 322 | - # is an integer number | |
| 323 | - elif split[3][0:3] == 'dev': | |
| 324 | - if split[3][3:].isdigit(): | |
| 325 | - check = True | |
| 431 | + # Set git repo | |
| 432 | + repo = 'https://cta-gitlab.irap.omp.eu/gammalib/gammalib.git' | |
| 433 | + | |
| 434 | + # Clone release branch | |
| 435 | + os.system('git clone -b %s %s %s' % (branch, repo, folder)) | |
| 326 | 436 | |
| 327 | - # Return check | |
| 328 | - return check | |
| 437 | + # Return | |
| 438 | + return | |
| 329 | 439 | |
| 330 | 440 | |
| 331 | 441 | # ================ # |
| ... | ... | @@ -338,13 +448,16 @@ def main_menu(): |
| 338 | 448 | # Print main menu |
| 339 | 449 | print('[1] Make a new package release') |
| 340 | 450 | print('[2] Set the package version') |
| 451 | + print('[3] Set the libtool version') | |
| 452 | + print('[4] Commit changes') | |
| 341 | 453 | print('[q] Quit') |
| 342 | 454 | |
| 343 | 455 | # Wait for the input |
| 344 | 456 | waiting = True |
| 345 | 457 | while waiting: |
| 346 | 458 | choice = str(raw_input('Enter your choice: ')) |
| 347 | - if choice == '1' or choice == '2' or choice == 'q': | |
| 459 | + if choice == '1' or choice == '2' or choice == '3' or choice == '4' or \ | |
| 460 | + choice == 'q': | |
| 348 | 461 | waiting = False |
| 349 | 462 | |
| 350 | 463 | # Return choice |
| ... | ... | @@ -354,24 +467,70 @@ def main_menu(): |
| 354 | 467 | # ====================== # |
| 355 | 468 | # Manage package release # |
| 356 | 469 | # ====================== # |
| 357 | -def release_menu(): | |
| 470 | +def release_menu(branch='release'): | |
| 358 | 471 | """ |
| 359 | 472 | Manage package release |
| 473 | + | |
| 474 | + Parameters | |
| 475 | + ---------- | |
| 476 | + branch : str, optional | |
| 477 | + Release branch name | |
| 360 | 478 | """ |
| 479 | + # Annonce actions | |
| 480 | + print("") | |
| 481 | + print("Make a new package release") | |
| 482 | + print("--------------------------") | |
| 483 | + | |
| 484 | + # Step 1: Create a release branch | |
| 485 | + if confirm("Step 1: Do you want to create a '%s' branch?" % branch): | |
| 486 | + create_git_branch(branch) | |
| 487 | + else: | |
| 488 | + if git_branch_exists(branch): | |
| 489 | + os.system('git checkout %s' % branch) | |
| 490 | + else: | |
| 491 | + requested = branch | |
| 492 | + branch = commands.getoutput('git rev-parse --abbrev-ref HEAD') | |
| 493 | + print("WARNING: No '%s' branch found, continue working on " | |
| 494 | + "current branch '%s'" % (requested, branch)) | |
| 495 | + | |
| 361 | 496 | # Get current package version |
| 362 | 497 | current = get_current_version() |
| 363 | 498 | |
| 364 | - # Create a new release branch | |
| 365 | - | |
| 366 | - # Set the package version | |
| 367 | - print(' Current GammaLib version is "%s"' % current) | |
| 368 | - if confirm(' Do you want to change the package version?'): | |
| 369 | - version_menu() | |
| 370 | - | |
| 371 | - # Commit changes | |
| 499 | + # Step 2: Set package version | |
| 500 | + print("") | |
| 501 | + if confirm("Step 2: Current GammaLib version is '%s'. Do you want to " | |
| 502 | + "change the package version?" % current): | |
| 503 | + package_version_menu() | |
| 504 | + | |
| 505 | + # Get current libtool version | |
| 506 | + current = get_libtool_version() | |
| 507 | + | |
| 508 | + # Step 3: Set libtool version | |
| 509 | + print("") | |
| 510 | + if confirm("Step 3: Current Libtool version is '%s'. Do you want to " | |
| 511 | + "change the libtool version?" % current): | |
| 512 | + libtool_version_menu() | |
| 513 | + | |
| 514 | + # Step 4: Commit changes | |
| 515 | + print("") | |
| 516 | + if confirm("Step 4: Commit changes?"): | |
| 517 | + package = get_current_version() | |
| 518 | + libtool = get_libtool_version() | |
| 519 | + message = "GammaLib package version set to '%s' and libtool version "\ | |
| 520 | + "set to '%s'" % (package, libtool) | |
| 521 | + commit(message) | |
| 522 | + | |
| 523 | + # Step 5: Push branch into git | |
| 524 | + print("") | |
| 525 | + if confirm("Step 5: Push changes?"): | |
| 526 | + os.system('git push origin %s' % branch) | |
| 527 | + | |
| 528 | + # Step 6: Build tarball | |
| 529 | + print("") | |
| 530 | + if confirm("Step 6: Build tarball?"): | |
| 531 | + folder = "gammalib-%s" % get_current_version() | |
| 532 | + build_tarball(branch, folder) | |
| 372 | 533 | |
| 373 | - # Create tarball | |
| 374 | - | |
| 375 | 534 | # Return |
| 376 | 535 | return |
| 377 | 536 | |
| ... | ... | @@ -379,16 +538,13 @@ def release_menu(): |
| 379 | 538 | # ============================== # |
| 380 | 539 | # Manage package version setting # |
| 381 | 540 | # ============================== # |
| 382 | -def version_menu(): | |
| 541 | +def package_version_menu(): | |
| 383 | 542 | """ |
| 384 | 543 | Manage package version setting |
| 385 | 544 | """ |
| 386 | 545 | # Get the current package version |
| 387 | 546 | current = get_current_version() |
| 388 | 547 | |
| 389 | - # Print current package version | |
| 390 | - print(' Current GammaLib version is "%s"' % current) | |
| 391 | - | |
| 392 | 548 | # Looping until the version change is accepted |
| 393 | 549 | looping = True |
| 394 | 550 | while looping: |
| ... | ... | @@ -396,39 +552,27 @@ def version_menu(): |
| 396 | 552 | # Get package version from input |
| 397 | 553 | waiting = True |
| 398 | 554 | while waiting: |
| 399 | - version = str(raw_input(' Please enter new GammaLib version: ')) | |
| 400 | - if version == 'q': | |
| 555 | + version = str(raw_input("Current GammaLib version is '%s'. Please " | |
| 556 | + "enter new GammaLib version: " % current)) | |
| 557 | + if version == "q": | |
| 401 | 558 | sys.exit() |
| 402 | 559 | if check_version(version) == False: |
| 403 | - print(' *** Invalid GammaLib version. ' | |
| 404 | - 'Please enter the version in the format x.y.z[.devn]') | |
| 560 | + print("*** Invalid GammaLib version. " | |
| 561 | + "Please enter the version in the format x.y.z[.devn]") | |
| 405 | 562 | else: |
| 406 | 563 | waiting = False |
| 407 | 564 | |
| 408 | 565 | # If the version number change is confirmed then do the change |
| 409 | - if confirm(' Change version to "%s"?' % version): | |
| 410 | - | |
| 411 | - # Determine package changes | |
| 412 | - library = confirm(' Has the source code changed since last release?') | |
| 413 | - added = confirm(' Have interfaces been added since last release?') | |
| 414 | - removed = confirm(' Have interfaces been removed since last release?') | |
| 415 | - changed = confirm(' Have interfaces changed since last release?') | |
| 566 | + if confirm("Change version to '%s'?" % version): | |
| 416 | 567 | |
| 417 | 568 | # Set package version |
| 418 | - set_package_version(version, library=library, added=added, | |
| 419 | - removed=removed, changed=changed) | |
| 569 | + set_package_version(version) | |
| 420 | 570 | |
| 421 | 571 | # Get new package and libtool versions |
| 422 | 572 | version = get_current_version() |
| 423 | - libtool = get_libtool_version() | |
| 424 | 573 | |
| 425 | 574 | # Inform about version change |
| 426 | - print(' GammaLib version changed to "%s", libtool version set to "%s"' % | |
| 427 | - (version, libtool)) | |
| 428 | - | |
| 429 | - # Ask whether changes should be committed | |
| 430 | - if confirm(' Should the changes be committed?'): | |
| 431 | - commit('GammaLib package version changed to %s' % version) | |
| 575 | + print("GammaLib version changed to '%s'" % (version)) | |
| 432 | 576 | |
| 433 | 577 | # Signal that we can exit looping |
| 434 | 578 | looping = False |
| ... | ... | @@ -437,65 +581,36 @@ def version_menu(): |
| 437 | 581 | return |
| 438 | 582 | |
| 439 | 583 | |
| 440 | -# ================= # | |
| 441 | -# Confirm something # | |
| 442 | -# ================= # | |
| 443 | -def confirm(text): | |
| 584 | +# ============================== # | |
| 585 | +# Manage libtool version setting # | |
| 586 | +# ============================== # | |
| 587 | +def libtool_version_menu(): | |
| 444 | 588 | """ |
| 445 | - Confirm something | |
| 446 | - | |
| 447 | - Parameters | |
| 448 | - ---------- | |
| 449 | - text : str | |
| 450 | - Thing to confirm | |
| 451 | - | |
| 452 | - Returns | |
| 453 | - ------- | |
| 454 | - flag : bool | |
| 455 | - True if something is confirmed | |
| 589 | + Manage libtool version setting | |
| 456 | 590 | """ |
| 457 | - # Confirmation loop | |
| 458 | - waiting = True | |
| 459 | - while waiting: | |
| 460 | - confirmation = str(raw_input(text+' (y/n): ')) | |
| 461 | - if confirmation == 'q': | |
| 462 | - sys.exit() | |
| 463 | - elif confirmation == 'y': | |
| 464 | - flag = True | |
| 465 | - waiting = False | |
| 466 | - elif confirmation == 'n': | |
| 467 | - flag = False | |
| 468 | - waiting = False | |
| 591 | + # Get current libtool version | |
| 592 | + current = get_libtool_version() | |
| 469 | 593 | |
| 470 | - # Return confirmation flag | |
| 471 | - return flag | |
| 594 | + # Continue only if libtool version should be changed | |
| 595 | + if confirm("Current libtool version is '%s'. Do you want to change the " | |
| 596 | + "version?" % current): | |
| 472 | 597 | |
| 598 | + # Determine package changes | |
| 599 | + library = confirm(" Has the source code changed since last release?") | |
| 600 | + added = confirm(" Have interfaces been added since last release?") | |
| 601 | + removed = confirm(" Have interfaces been removed since last release?") | |
| 602 | + changed = confirm(" Have interfaces changed since last release?") | |
| 473 | 603 | |
| 474 | -# ============== # | |
| 475 | -# Commit changes # | |
| 476 | -# ============== # | |
| 477 | -def commit(message): | |
| 478 | - """ | |
| 479 | - Commit changes into Git repo | |
| 604 | + # Set libtool version | |
| 605 | + set_libtool_version(library=library, added=added, removed=removed, | |
| 606 | + changed=changed) | |
| 480 | 607 | |
| 481 | - Parameters | |
| 482 | - ---------- | |
| 483 | - message : str | |
| 484 | - Commit message | |
| 485 | - """ | |
| 486 | - # Show changes | |
| 487 | - print(' The following files have been changed:') | |
| 488 | - os.system('git status -s') | |
| 608 | + # Get new libtool version | |
| 609 | + version = get_libtool_version() | |
| 489 | 610 | |
| 490 | - # Ask again whether the changes should be committed | |
| 491 | - if confirm(' Commit all changes?'): | |
| 492 | - | |
| 493 | - # Stage all files | |
| 494 | - os.system('git add -u') | |
| 611 | + # Print new libtool version | |
| 612 | + print("Libtool version changed to '%s'" % version) | |
| 495 | 613 | |
| 496 | - # Commit all changes | |
| 497 | - os.system('git commit -m "%s"' % message) | |
| 498 | - | |
| 499 | 614 | # Return |
| 500 | 615 | return |
| 501 | 616 | |
| ... | ... | @@ -522,8 +637,16 @@ if __name__ == '__main__': |
| 522 | 637 | # Dispatch according to choice |
| 523 | 638 | if choice == '1': |
| 524 | 639 | release_menu() |
| 640 | + print('') | |
| 525 | 641 | elif choice == '2': |
| 526 | - version_menu() | |
| 642 | + package_version_menu() | |
| 643 | + print('') | |
| 644 | + elif choice == '3': | |
| 645 | + libtool_version_menu() | |
| 646 | + print('') | |
| 647 | + elif choice == '4': | |
| 648 | + commit('') | |
| 649 | + print('') | |
| 527 | 650 | elif choice == 'q': |
| 528 | 651 | break |
| 529 | 652 | ... | ... |