Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
Revert "Version is now built dynamically"
Browse files Browse the repository at this point in the history
This reverts commit 64bb58b.
  • Loading branch information
AlexChesters committed Oct 17, 2015
1 parent 64bb58b commit bad9794
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions ghi
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#!/usr/bin/env ruby
# encoding: utf-8
require 'net/http'
require 'json'

module GHI
module Commands
module Version
MAJOR = 1
MINOR = 0
PATCH = 0
PRE = nil

VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join '.'

def self.execute args
puts "ghi version #{get_latest_version}"
puts "ghi version #{VERSION}"
end

def self.get_latest_version
result = JSON.parse(Net::HTTP.get(URI.parse('https://api.github.com/repos/stephencelis/ghi/releases/latest')))
return result['tag_name']
end

end
end
end
Expand Down Expand Up @@ -2514,7 +2511,6 @@ EOF
end
require 'cgi'
require 'net/https'
require_relative './lib/ghi/commands/version'

unless defined? Net::HTTP::Patch
# PATCH support for 1.8.7.
Expand Down Expand Up @@ -2559,7 +2555,11 @@ module GHI
end

CONTENT_TYPE = 'application/vnd.github.beta+json'
USER_AGENT = "ghi/#{GHI::Commands::Version::get_latest_version}"
USER_AGENT = 'ghi/%s (%s; +%s)' % [
GHI::Commands::Version::VERSION,
RUBY_DESCRIPTION,
'https://github.com/stephencelis/ghi'
]
METHODS = {
:head => Net::HTTP::Head,
:get => Net::HTTP::Get,
Expand Down
2 changes: 1 addition & 1 deletion ghi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'ghi/commands/version'

Gem::Specification.new do |s|
s.name = 'ghi'
s.version = GHI::Commands::Version::get_latest_version
s.version = GHI::Commands::Version::VERSION
s.summary = 'GitHub Issues command line interface'
s.description = <<EOF
GitHub Issues on the command line. Use your `$EDITOR`, not your browser.
Expand Down
7 changes: 5 additions & 2 deletions lib/ghi/client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'cgi'
require 'net/https'
require_relative './lib/ghi/commands/version'

unless defined? Net::HTTP::Patch
# PATCH support for 1.8.7.
Expand Down Expand Up @@ -47,7 +46,11 @@ def links
end

CONTENT_TYPE = 'application/vnd.github.beta+json'
USER_AGENT = "ghi/#{GHI::Commands::Version::get_latest_version}"
USER_AGENT = 'ghi/%s (%s; +%s)' % [
GHI::Commands::Version::VERSION,
RUBY_DESCRIPTION,
'https://github.com/stephencelis/ghi'
]
METHODS = {
:head => Net::HTTP::Head,
:get => Net::HTTP::Get,
Expand Down
17 changes: 7 additions & 10 deletions lib/ghi/commands/version.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
require 'net/http'
require 'json'

module GHI
module Commands
module Version
MAJOR = 1
MINOR = 0
PATCH = 0
PRE = nil

VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join '.'

def self.execute args
puts "ghi version #{get_latest_version}"
puts "ghi version #{VERSION}"
end

def self.get_latest_version
result = JSON.parse(Net::HTTP.get(URI.parse('https://api.github.com/repos/stephencelis/ghi/releases/latest')))
return result['tag_name']
end

end
end
end

0 comments on commit bad9794

Please sign in to comment.