gitclean 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +59 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/gitclean +10 -0
- data/bin/setup +8 -0
- data/gitclean.gemspec +39 -0
- data/lib/gitclean.rb +2 -0
- data/lib/gitclean/cli.rb +36 -0
- data/lib/gitclean/git_commands.rb +19 -0
- data/lib/gitclean/script_options.rb +41 -0
- data/lib/gitclean/version.rb +3 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33aaa5399c211728b7126845b3a35b403f324c3e16bee42fa6b72ed661e5ff3f
|
4
|
+
data.tar.gz: 510a775f6ed1c31783e670e4336bd8b12f9ad3da8a8d40c649549c4659ad8925
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2288304ec55c5730951c18ffc26b031562bca6304497d0ebdd58d8293d99bcf37644ad8f65408e5078c5e6b0a06e202df2745b2d5ea87ae8f914da1a563652e2
|
7
|
+
data.tar.gz: 32a013942fbfe9cc381b002fcbe33475bd901f7f9d17474b2f0c4199c1c36285431194dc6261b98f39734bc458dd69b5a9e2008d48cafb4a4daac2101cd3d68e
|
data/.gitignore
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
### Ruby ###
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
/.config
|
5
|
+
/coverage/
|
6
|
+
/InstalledFiles
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/spec/examples.txt
|
10
|
+
/test/tmp/
|
11
|
+
/test/version_tmp/
|
12
|
+
/tmp/
|
13
|
+
|
14
|
+
# Used by dotenv library to load environment variables.
|
15
|
+
# .env
|
16
|
+
|
17
|
+
# Ignore Byebug command history file.
|
18
|
+
.byebug_history
|
19
|
+
|
20
|
+
## Specific to RubyMotion:
|
21
|
+
.dat*
|
22
|
+
.repl_history
|
23
|
+
build/
|
24
|
+
*.bridgesupport
|
25
|
+
build-iPhoneOS/
|
26
|
+
build-iPhoneSimulator/
|
27
|
+
|
28
|
+
## Specific to RubyMotion (use of CocoaPods):
|
29
|
+
#
|
30
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
31
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
32
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
### Ruby Patch ###
|
56
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
57
|
+
# .rubocop-https?--*
|
58
|
+
|
59
|
+
# End of https://www.gitignore.io/api/ruby
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Omar Guerrero
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Gitclean
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gitclean`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'gitclean'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install gitclean
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gitclean.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gitclean"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/gitclean
ADDED
data/bin/setup
ADDED
data/gitclean.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "gitclean/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gitclean"
|
7
|
+
spec.version = Gitclean::VERSION
|
8
|
+
spec.authors = ["Omar Guerrero"]
|
9
|
+
spec.email = ["guerrero9725@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{A command-line tool to keep clean your git repositories.}
|
12
|
+
spec.homepage = "https://github.com/Guerrero25/gitclean"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
19
|
+
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/Guerrero25/gitclean"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/Guerrero25/gitclean"
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "bin"
|
34
|
+
spec.executables = ["gitclean"]
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
end
|
data/lib/gitclean.rb
ADDED
data/lib/gitclean/cli.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require "optparse"
|
3
|
+
|
4
|
+
require_relative "script_options"
|
5
|
+
require_relative "git_commands"
|
6
|
+
|
7
|
+
module Gitclean
|
8
|
+
class CLI
|
9
|
+
include GitCommands
|
10
|
+
#
|
11
|
+
# Return a structure describing the options.
|
12
|
+
#
|
13
|
+
def parse(args)
|
14
|
+
# The options specified on the command line will be collected in
|
15
|
+
# *options*.
|
16
|
+
@options = ScriptOptions.new
|
17
|
+
|
18
|
+
@args = OptionParser.new do |parser|
|
19
|
+
@options.define_options(parser)
|
20
|
+
parser.parse!(args)
|
21
|
+
end
|
22
|
+
|
23
|
+
@options
|
24
|
+
end
|
25
|
+
|
26
|
+
def run()
|
27
|
+
branches = get_git_branches - @options.exemptions
|
28
|
+
|
29
|
+
delete_git_branches(branches)
|
30
|
+
|
31
|
+
puts "Branches were cleaned up - #{branches.size} deleted"
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :parser, :options
|
35
|
+
end # class GitClean
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GitCommands
|
2
|
+
def get_git_branches
|
3
|
+
branches = %x`git branch`.split.select do |branch|
|
4
|
+
branch != "*"
|
5
|
+
end
|
6
|
+
|
7
|
+
branches
|
8
|
+
end
|
9
|
+
|
10
|
+
def delete_git_branches(branches)
|
11
|
+
branches.each do |branch|
|
12
|
+
%x`git branch -D #{branch}`
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def show_git_branches
|
17
|
+
%x`git branch`
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative "version"
|
2
|
+
|
3
|
+
module Gitclean
|
4
|
+
class ScriptOptions
|
5
|
+
attr_accessor :exemptions
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
self.exemptions = ["master", "develope", "staging"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def define_options(parser)
|
12
|
+
parser.banner = "Usage: run.rb [options]"
|
13
|
+
parser.separator ""
|
14
|
+
parser.separator "Specific options:"
|
15
|
+
|
16
|
+
# add additional options
|
17
|
+
exemption_list_option(parser)
|
18
|
+
|
19
|
+
parser.separator ""
|
20
|
+
parser.separator "Common options:"
|
21
|
+
# No argument, shows at tail. This will print an options summary.
|
22
|
+
# Try it and see!
|
23
|
+
parser.on_tail("-h", "--help", "Show this message") do
|
24
|
+
puts parser
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
# Another typical switch to print the version.
|
28
|
+
parser.on_tail("--version", "Show version") do
|
29
|
+
puts "GitClean CLI version #{VERSION}"
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def exemption_list_option(parser)
|
35
|
+
# List of arguments.
|
36
|
+
parser.on("--exemption x,y,z", Array, "Items which should not be deleted") do |list|
|
37
|
+
self.exemptions = list
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitclean
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Omar Guerrero
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- guerrero9725@gmail.com
|
44
|
+
executables:
|
45
|
+
- gitclean
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/console
|
56
|
+
- bin/gitclean
|
57
|
+
- bin/setup
|
58
|
+
- gitclean.gemspec
|
59
|
+
- lib/gitclean.rb
|
60
|
+
- lib/gitclean/cli.rb
|
61
|
+
- lib/gitclean/git_commands.rb
|
62
|
+
- lib/gitclean/script_options.rb
|
63
|
+
- lib/gitclean/version.rb
|
64
|
+
homepage: https://github.com/Guerrero25/gitclean
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
allowed_push_host: https://rubygems.org
|
69
|
+
homepage_uri: https://github.com/Guerrero25/gitclean
|
70
|
+
source_code_uri: https://github.com/Guerrero25/gitclean
|
71
|
+
changelog_uri: https://github.com/Guerrero25/gitclean
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubygems_version: 3.0.3
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: A command-line tool to keep clean your git repositories.
|
91
|
+
test_files: []
|