Get the previous version by looking at git tags.
()
| 83 | |
| 84 | |
| 85 | def get_previous_version() -> Optional[str]: |
| 86 | """Get the previous version by looking at git tags.""" |
| 87 | try: |
| 88 | # Get all version tags, sorted by version |
| 89 | tags_output = run_cmd( |
| 90 | "git tag -l | grep -E '^v[0-9]+\\.[0-9]+\\.[0-9]+$' | sort -V", |
| 91 | capture_output=True, |
| 92 | check=False, |
| 93 | ) |
| 94 | if not tags_output: |
| 95 | return None |
| 96 | |
| 97 | tags = tags_output.strip().split("\n") |
| 98 | if len(tags) >= 1: |
| 99 | # Return the latest tag without the 'v' prefix |
| 100 | return tags[-1][1:] # Remove 'v' prefix |
| 101 | return None |
| 102 | except Exception: |
| 103 | return None |
| 104 | |
| 105 | |
| 106 | def get_git_diff_since_version(previous_version: Optional[str]) -> str: |
no test coverage detected