-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop using __LINE_BOT_SDK_PYTHON_VERSION__ #710
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2367a77
NO-ISSUE Stop using __LINE_BOT_SDK_PYTHON_VERSION__
Yang-33 eae415f
NO-ISSUE Fix
Yang-33 f4ebfe5
Add script to update and verify version
Yang-33 5eb82cd
Add useful output
Yang-33 eff9517
NO-ISSUE Delete test
Yang-33 e3ca659
Update .github/workflows/publish-to-pypi.yml
Yang-33 b5607c7
Update tools/update_version.py
Yang-33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import sys | ||
import re | ||
import subprocess | ||
|
||
def update_and_verify_version(new_version): | ||
file_path = 'linebot/__about__.py' | ||
|
||
# Update version | ||
with open(file_path, 'r') as file: | ||
content = file.read() | ||
|
||
new_content = re.sub( | ||
r"__version__ = '.*?'", | ||
f"__version__ = '{new_version}'", | ||
content | ||
) | ||
|
||
with open(file_path, 'w') as file: | ||
file.write(new_content) | ||
|
||
print(f"Updated version to {new_version} in {file_path}") | ||
|
||
# verify version | ||
match = re.search(r"__version__ = '(.*?)'", new_content) | ||
if not match: | ||
raise ValueError("Version string not found in the file.") | ||
|
||
actual_version = match.group(1) | ||
if actual_version != new_version: | ||
raise ValueError(f"Version mismatch: expected {new_version}, found {actual_version}") | ||
|
||
print(f"Version verified: {actual_version}") | ||
|
||
# diff check just in case | ||
try: | ||
result = subprocess.run(['git', 'diff', '--numstat', file_path], capture_output=True, text=True, check=True) | ||
changed_lines = result.stdout.strip().split('\n') | ||
added_lines = 0 | ||
deleted_lines = 0 | ||
|
||
for line in changed_lines: | ||
added, deleted = map(int, line.split('\t')[:2]) | ||
added_lines += added | ||
deleted_lines += deleted | ||
|
||
if added_lines != 1 or deleted_lines != 1: | ||
raise ValueError(f"Unexpected number of changed lines: expected 1 added and 1 deleted, found {added_lines} added and {deleted_lines} deleted") | ||
|
||
print('Git diff verification passed: 1 line added and 1 line deleted.') | ||
|
||
# Show diff | ||
diff_result = subprocess.run(['git', 'diff', '--color=always', file_path], capture_output=True, text=True, check=True) | ||
print('Git diff output:\n', diff_result.stdout) | ||
|
||
except subprocess.CalledProcessError as e: | ||
print(f"Error during git diff verification: {e}") | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python update_version.py <new_version>") | ||
sys.exit(1) | ||
|
||
new_version = sys.argv[1] | ||
|
||
try: | ||
update_and_verify_version(new_version) | ||
except ValueError as e: | ||
print(e) | ||
sys.exit(1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(for unexpected failure)