-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: dblock <[email protected]>
- Loading branch information
Showing
5 changed files
with
75 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bin | ||
class Commands | ||
desc 'Releases.' | ||
command 'releases' do |g| | ||
g.flag %i[o org], desc: 'Name of the GitHub organization.', default_value: 'opensearch-project' | ||
g.flag %i[repo], multiple: true, desc: 'Search a specific repo within the org.' | ||
g.flag %i[from], desc: 'Start at.', default_value: Date.today.beginning_of_week.last_week | ||
g.flag %i[to], desc: 'End at.', default_value: Date.today.beginning_of_week - 1 | ||
|
||
g.desc 'Display releases last week.' | ||
g.command 'latest' do |c| | ||
c.action do |_global_options, options, _args| | ||
repos = if options[:repo]&.any? | ||
GitHub::Repos.new(options[:repo]) | ||
else | ||
GitHub::Organization.new(options.merge(org: options['org'] || 'opensearch-project')).repos | ||
end | ||
from = Chronic.parse(options[:from]).to_date if options[:from] | ||
to = Chronic.parse(options[:to]).to_date if options[:to] | ||
repos.sort_by(&:name).each do |repo| | ||
release = repo.latest_release | ||
next unless release | ||
next if from && release.created_at < from | ||
next if to && release.created_at > to | ||
|
||
puts "#{repo.name}: #{release}" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module GitHub | ||
class Release < Item | ||
def to_s | ||
[ | ||
"#{name}, created #{DOTIW::Methods.distance_of_time_in_words(created_at, Time.now, highest_measures: 1)} ago", | ||
" #{html_url}" | ||
].join("\n") | ||
end | ||
end | ||
end |
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