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.
@@ -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
@@ -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
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in gitclean.gemspec
6
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitclean (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ x64-mingw32
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.17)
16
+ gitclean!
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 1.17.2
@@ -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.
@@ -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).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -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__)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+
5
+ require "gitclean/cli"
6
+
7
+ git_clean = Gitclean::CLI.new
8
+ git_clean.parse(ARGV)
9
+
10
+ git_clean.run
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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
@@ -0,0 +1,2 @@
1
+ require "gitclean/version"
2
+ require "gitclean/cli"
@@ -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
@@ -0,0 +1,3 @@
1
+ module Gitclean
2
+ VERSION = "0.1.0"
3
+ 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: []