-
Notifications
You must be signed in to change notification settings - Fork 0
Improve error handling in user authentication #8
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
Conversation
Enhance the error handling mechanism during user authentication to provide clearer feedback and improve user experience.
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.
Summary of Changes
Hello @jsonify, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a comprehensive automated version management system for the ClickIt application. It establishes GitHub release tags as the single source of truth for the application's version, ensuring synchronization across the Info.plist (which dictates the UI version), build processes, and release artifacts. This system includes new scripts for syncing, validating, and updating versions, as well as integrating these checks into Fastlane lanes and git pre-commit hooks. It's important to note that the PR title and description (Improve error handling in user authentication) do not accurately reflect the changes implemented, which are entirely focused on versioning.
Highlights
- Automated Version Management System: Implemented a new system where GitHub release tags serve as the single source of truth for the application's version. This ensures synchronization across the
Info.plist(which dictates the UI version), build processes, and release artifacts. - New Versioning Scripts: Added dedicated shell scripts (
sync-version-from-github.sh,validate-github-version-sync.sh,update-version.sh) to automate version synchronization, validation, and the entire release workflow, including updatingInfo.plist, committing, and tagging. - Fastlane Integration: Introduced new Fastlane lanes (
validate_github_sync,sync_version_with_github) and integrated version validation and auto-sync capabilities into the existingdevlane for a more streamlined development experience. - Git Pre-commit Hook: Added a new pre-commit hook (
.githooks/pre-commit) and an installation script (scripts/install-git-hooks.sh) to provide warnings about version mismatches before commits, promoting version consistency. - Build Process Enhancements: Modified
build_app_unified.shto dynamically read the application version fromInfo.plistand include a validation step against the latest GitHub release tag during the build process, alerting developers to potential discrepancies. - Info.plist Version Update: Updated the
CFBundleShortVersionStringinClickIt/Info.plistfrom1.2.0to1.4.15as part of the versioning system setup.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces an excellent and comprehensive version management system that automates synchronizing the project's version from GitHub releases. This is a great improvement for maintainability and ensuring version consistency. My review includes a critical fix for a typo in a script, suggestions to handle edge cases where a version might not be found, and recommendations to reduce code duplication for better long-term maintenance. I also noted that the PR title and description seem to be for a different change and could be updated to reflect this new versioning system.
| /usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $NEW_VERSION" ClickIt/Info.plist | ||
|
|
||
| # Verify the change | ||
| UPDATED_VERSION=$(/usr/libexec/PListBuddy -c "Print CFBundleShortVersionString" ClickIt/Info.plist) |
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.
There is a typo in the command PListBuddy. It should be PlistBuddy. This typo will cause the script to fail at this verification step.
| UPDATED_VERSION=$(/usr/libexec/PListBuddy -c "Print CFBundleShortVersionString" ClickIt/Info.plist) | |
| UPDATED_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ClickIt/Info.plist) |
| # Get versions | ||
| plist_version = sh("/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' ClickIt/Info.plist", log: false).strip | ||
| github_tag = sh("gh release list --limit 1 --json tagName --jq '.[0].tagName'", log: false).strip | ||
| github_version = github_tag.gsub(/^v/, '') | ||
|
|
||
| UI.message("📋 Version Status:") | ||
| UI.message(" Info.plist (UI): #{plist_version}") | ||
| UI.message(" GitHub Release: #{github_version}") | ||
|
|
||
| if plist_version != github_version | ||
| UI.error("") | ||
| UI.error("❌ VERSION MISMATCH DETECTED!") | ||
| UI.error(" The UI will show v#{plist_version}") | ||
| UI.error(" But the latest release is #{github_tag}") | ||
| UI.error("") | ||
| UI.error("🔧 To fix, run: fastlane sync_version_with_github") | ||
| UI.user_error!("Version synchronization required") | ||
| else | ||
| UI.success("✅ Versions are synchronized") | ||
| UI.success(" UI will display: v#{plist_version}") | ||
| UI.success(" GitHub release: #{github_tag}") | ||
| end | ||
|
|
||
| rescue => exception | ||
| UI.error("❌ GitHub CLI not available or authentication failed") | ||
| raise exception |
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.
To improve maintainability and avoid duplicating logic, this lane could be simplified to execute the validate-github-version-sync.sh script directly. The shell script already contains all the necessary validation logic and user-friendly output.
# Get versions
plist_version = sh("/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' ClickIt/Info.plist", log: false).strip
github_tag = sh("gh release list --limit 1 --json tagName --jq '.[0].tagName'", log: false).strip
github_version = github_tag.gsub(/^v/, '')
UI.message("📋 Version Status:")
UI.message(" Info.plist (UI): #{plist_version}")
UI.message(" GitHub Release: #{github_version}")
if plist_version != github_version
UI.error("")
UI.error("❌ VERSION MISMATCH DETECTED!")
UI.error(" The UI will show v#{plist_version}")
UI.error(" But the latest release is #{github_tag}")
UI.error("")
UI.error("🔧 To fix, run: fastlane sync_version_with_github")
UI.user_error!("Version synchronization required")
else
UI.success("✅ Versions are synchronized")
UI.success(" UI will display: v#{plist_version}")
UI.success(" GitHub release: #{github_tag}")
end
| begin | ||
| # Try GitHub CLI first | ||
| latest_release = sh("gh release list --limit 1 --json tagName --jq '.[0].tagName'", log: false).strip | ||
| version = latest_release.gsub(/^v/, '') | ||
|
|
||
| UI.message("📦 Latest GitHub release: #{latest_release}") | ||
| UI.message("📝 Extracted version: #{version}") | ||
|
|
||
| rescue => gh_exception | ||
| # Fallback to git tags if GitHub CLI fails | ||
| UI.message("⚠️ GitHub CLI unavailable, falling back to git tags...") | ||
| begin | ||
| latest_tag = sh("git describe --tags --abbrev=0", log: false).strip | ||
| version = latest_tag.gsub(/^v/, '') | ||
| UI.message("📦 Latest git tag: #{latest_tag}") | ||
| UI.message("📝 Extracted version: #{version}") | ||
| rescue => git_exception | ||
| if options[:auto_sync] | ||
| UI.error("❌ Cannot determine latest version (GitHub CLI and git tags both failed)") | ||
| raise "Auto-sync failed: No version source available" | ||
| else | ||
| UI.error("❌ GitHub CLI not available or not authenticated") | ||
| UI.message("Install GitHub CLI: brew install gh") | ||
| UI.message("Authenticate: gh auth login") | ||
| raise gh_exception | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # Get current Info.plist version | ||
| current_version = sh("/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' ClickIt/Info.plist", log: false).strip | ||
|
|
||
| if version != current_version | ||
| UI.message("⚠️ Version mismatch detected!") | ||
| UI.message(" Info.plist: #{current_version}") | ||
| UI.message(" Latest release/tag: #{version}") | ||
| UI.message("") | ||
| UI.message("🔧 Updating Info.plist to match latest version...") | ||
|
|
||
| # Update Info.plist | ||
| sh("/usr/libexec/PlistBuddy -c 'Set CFBundleShortVersionString #{version}' ClickIt/Info.plist") | ||
|
|
||
| UI.success("✅ Info.plist updated to v#{version}") | ||
| UI.success("🔄 UI will now display v#{version}") | ||
| else | ||
| UI.success("✅ Versions are synchronized (v#{version})") | ||
| end |
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.
Similar to validate_github_sync, this lane duplicates logic already present in scripts/sync-version-from-github.sh. To keep the logic centralized and easier to maintain, this lane should call the shell script instead of reimplementing the version fetching and Info.plist update logic.
# Try GitHub CLI first
latest_release = sh("gh release list --limit 1 --json tagName --jq '.[0].tagName'", log: false).strip
version = latest_release.gsub(/^v/, '')
UI.message("📦 Latest GitHub release: #{latest_release}")
UI.message("📝 Extracted version: #{version}")
rescue => gh_exception
# Fallback to git tags if GitHub CLI fails
UI.message("⚠️ GitHub CLI unavailable, falling back to git tags...")
begin
latest_tag = sh("git describe --tags --abbrev=0", log: false).strip
version = latest_tag.gsub(/^v/, '')
UI.message("📦 Latest git tag: #{latest_tag}")
UI.message("📝 Extracted version: #{version}")
rescue => git_exception
if options[:auto_sync]
UI.error("❌ Cannot determine latest version (GitHub CLI and git tags both failed)")
raise "Auto-sync failed: No version source available"
else
UI.error("❌ GitHub CLI not available or not authenticated")
UI.message("Install GitHub CLI: brew install gh")
UI.message("Authenticate: gh auth login")
raise gh_exception
end
end
end
# Get current Info.plist version
current_version = sh("/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' ClickIt/Info.plist", log: false).strip
if version != current_version
UI.message("⚠️ Version mismatch detected!")
UI.message(" Info.plist: #{current_version}")
UI.message(" Latest release/tag: #{version}")
UI.message("")
UI.message("🔧 Updating Info.plist to match latest version...")
# Update Info.plist
sh("/usr/libexec/PlistBuddy -c 'Set CFBundleShortVersionString #{version}' ClickIt/Info.plist")
UI.success("✅ Info.plist updated to v#{version}")
UI.success("🔄 UI will now display v#{version}")
else
UI.success("✅ Versions are synchronized (v#{version})")
end
Enhance the error handling mechanism during user authentication to provide clearer feedback and improve user experience.