-
Notifications
You must be signed in to change notification settings - Fork 620
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
Add --version command and version metadata #1384
base: main
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
5a187a9
to
26a5f43
Compare
pyproject.toml
Outdated
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |||
|
|||
[project] | |||
name = "pr-agent" | |||
version = "0.2.4" | |||
version = "0.2.6" |
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.
the current version is 0.2.5
pr_agent/version.py
Outdated
import os | ||
import sys | ||
from importlib.metadata import version, PackageNotFoundError | ||
|
||
from pr_agent.log import get_logger | ||
|
||
def get_version() -> str: | ||
# First check pyproject.toml if running directly out of repository | ||
if os.path.exists("pyproject.toml"): | ||
if sys.version_info >= (3, 11): | ||
import tomllib | ||
with open("pyproject.toml", "rb") as f: | ||
data = tomllib.load(f) | ||
return data["project"]["version"] | ||
else: | ||
get_logger().error("Unable to determine local version from pyproject.toml") | ||
|
||
# Otherwise get the installed pip package version | ||
try: | ||
return version('pr-agent') | ||
except PackageNotFoundError: | ||
get_logger().error("Unable to find package named 'pr-agent'") | ||
return "unknown" |
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.
add this to an existing util
file. no need for new file
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.
Which one should it go in?
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.
looks good. after fixing the feedback, can be merged |
26a5f43
to
452abe2
Compare
User description
Implements #1370
Checks version info from pyproject.toml if running locally* before checking for pip metadata.
PR Type
enhancement
Description
get_version
function to retrieve version information frompyproject.toml
or pip metadata.--version
command in the CLI to display the current version of the application.pyproject.toml
to 0.2.6.Changes walkthrough 📝
litellm_ai_handler.py
Add version metadata to logging tags
pr_agent/algo/ai_handlers/litellm_ai_handler.py
get_version
frompr_agent.version
.capture_logs
function.cli.py
Implement --version command in CLI
pr_agent/cli.py
get_version
frompr_agent.version
.--version
command to CLI.version.py
Add version retrieval utility
pr_agent/version.py
get_version
function to retrieve version frompyproject.toml
or pip metadata.
pyproject.toml
Update project version in pyproject.toml
pyproject.toml