-
Notifications
You must be signed in to change notification settings - Fork 2
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
Max Larionov - Github-team-remover progress(Finished.) #3
Open
maxinspace
wants to merge
14
commits into
FlatstackSchool:master
Choose a base branch
from
maxinspace:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
488f8df
Started work, created commander class && 1-easy task done
maxinspace 6c456cb
Added color as --c color ! Started working on verbose! Look comments!
maxinspace b357104
added specs & made code readable a bit
maxinspace 052e05a
bugfix with CLI
maxinspace 29e78b2
added --verbose, will make another class for reporting soon
maxinspace a424990
verbose color delete works now, check comments
maxinspace a96ebc2
bugfixes
maxinspace 4a5f510
added Remover class, look comments
maxinspace 9f95957
quality fixes
maxinspace f80a83d
spec fixes
maxinspace 35ea487
delete fix
maxinspace b99d78c
now works everything, thanks to Bulat PC
bulatsitdikov 04df849
All is done! Quality fixes
maxinspace ad8307d
Update README.md
maxinspace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
require 'bundler/setup' | ||
|
||
require 'rubygems' | ||
require 'remover' | ||
|
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,28 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
|
||
require 'remover/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "github-team-remover" | ||
spec.version = Remover::VERSION | ||
spec.authors = ["Flatstack School"] | ||
spec.email = ["[email protected]"] | ||
spec.summary = %q{Show empty teams on github} | ||
spec.description = %q{Show empty teams on github. Teams without members or tems without repositories.} | ||
spec.homepage = "http://github.com/FlatstackSchool/github-team-remover" | ||
spec.license = "MIT" | ||
|
||
spec.files = `git ls-files -z`.split("\x0") | ||
spec.executables = ['github-team-remover'] | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_dependency 'octokit', '~> 3.0' | ||
spec.add_dependency 'thor' | ||
spec.add_dependency 'colorize' | ||
|
||
spec.add_development_dependency 'rubocop' | ||
spec.add_development_dependency 'rspec', '~> 3.0.0.beta2' | ||
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
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,63 @@ | ||
require 'colorize' | ||
|
||
module Remover | ||
class Reporter | ||
attr_accessor :unused_team, :color, :verbose, :delete | ||
|
||
def initialize(unused_team, color, verbose, delete) | ||
@unused_team, @color, @verbose, @delete = unused_team, color, verbose, delete | ||
end | ||
|
||
def report_to_cli | ||
puts ' ------------------------------'.colorize(color_it) | ||
team_name | ||
members_amount | ||
members_url if verbose? | ||
repos_amount | ||
repos_url if verbose? | ||
report_and_delete if delete? | ||
puts ' ------------------------------'.colorize(color_it) | ||
end | ||
|
||
private | ||
|
||
def verbose? | ||
true if @verbose | ||
end | ||
|
||
def delete? | ||
true if @delete | ||
end | ||
|
||
def team_name | ||
puts " Team name: #{unused_team.name}".colorize(color_it) | ||
end | ||
|
||
def members_amount | ||
puts " Members: #{unused_team.members_amount}".colorize(color_it) | ||
end | ||
|
||
def members_url | ||
puts ' Members URL:'.colorize(color_it) | ||
puts " #{unused_team.members_url.colorize(:yellow)}" if verbose? | ||
end | ||
|
||
def repos_amount | ||
puts " Repositories: #{unused_team.repositories_amount}".colorize(color_it) | ||
end | ||
|
||
def repos_url | ||
puts ' Repositories URL:'.colorize(color) | ||
puts " #{unused_team.repositories_url.colorize(:yellow)}" if verbose? | ||
end | ||
|
||
def report_and_delete | ||
puts ' !DELETED!'.colorize(:red) if delete | ||
unused_team.delete_team | ||
end | ||
|
||
def color_it | ||
color | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
describe Remover::CLI do | ||
let(:options) do | ||
{ 'organization' => 'FlatSchool', | ||
'login' => 'fs-school', | ||
'password' => '123456', | ||
'color' => :blue, | ||
'verbose' => 'true', | ||
'delete' => 'true' | ||
} | ||
end | ||
|
||
let(:configuration) { Remover::Configuration.new } | ||
|
||
describe '#color' do | ||
before do | ||
configuration.load_from_options!(options) | ||
end | ||
|
||
it 'returns true' do | ||
expect(configuration.color).to eq(:blue) | ||
end | ||
|
||
context '--color not used' do | ||
let(:options) do | ||
{ | ||
'color' => :white | ||
} | ||
end | ||
|
||
it 'is default => :white' do | ||
expect(configuration.color).to eq(:white) | ||
end | ||
end | ||
end | ||
|
||
describe '#verbose' do | ||
before do | ||
configuration.load_from_options!(options) | ||
end | ||
|
||
it 'returns true' do | ||
expect(configuration.verbose).to eq('true') | ||
end | ||
|
||
context '--verbose not used' do | ||
let(:options) do | ||
{ | ||
'verbose' => 'false' | ||
} | ||
end | ||
it 'returns false' do | ||
expect(configuration.verbose).not_to eq('true') | ||
end | ||
end | ||
end | ||
|
||
describe '#delete_team' do | ||
before do | ||
configuration.load_from_options!(options) | ||
end | ||
|
||
it 'returns true' do | ||
expect(configuration.delete).to eq('true') | ||
end | ||
|
||
context 'if --delete key not entered' do | ||
let(:options) do | ||
{ | ||
'delete' => 'false' | ||
} | ||
end | ||
|
||
it 'returns false' do | ||
expect(configuration.delete).not_to eq('true') | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you please use these new methods in the
with_members?
andwith_repositories?
also?