-
Notifications
You must be signed in to change notification settings - Fork 106
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
(SDK-274) Adds --version option #90
Changes from 3 commits
04a1ae1
847509f
2e172cd
a5f4deb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'pdk/version' | ||
require 'pdk/cli/exec' | ||
|
||
module PDK | ||
module Util | ||
module Version | ||
def self.version_string | ||
"#{PDK::VERSION} #{pdk_ref}".strip.freeze | ||
end | ||
|
||
def self.pdk_ref | ||
ref = pkg_sha || git_ref | ||
ref.nil? ? nil : "(#{ref})" | ||
end | ||
|
||
def self.pkg_sha | ||
version_file = File.join(File.expand_path('../../..', File.dirname(__FILE__)), 'VERSION') | ||
|
||
if File.exist? version_file | ||
ver = File.read(version_file) | ||
sha = ver.strip.split('.')[-1] unless ver.nil? | ||
end | ||
|
||
sha | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the version file doesn't exist, I'm expecting it to return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, ruby hoists vars out of |
||
end | ||
|
||
def self.git_ref | ||
ref_result = PDK::CLI::Exec.git('--git-dir', File.join(File.expand_path('../../..', File.dirname(__FILE__)), '.git'), 'describe', '--all', '--long') | ||
|
||
ref_result[:stdout].strip if ref_result[:exit_code].zero? | ||
end | ||
end | ||
end | ||
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.
Debating flipping this prioritization. I think if someone installs the official pdk package, but modifies the underlying code (with an initialized git repo), we should be aware of that.
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.
In that case it would be good to know both, so maybe they should just each be conditionally added if available?