git-squash 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c6bce93d7b1b948e4b38376f39203fab12d9d88
4
+ data.tar.gz: e14dee1d4497a07de18c17e47557c6424631fc2b
5
+ SHA512:
6
+ metadata.gz: b1cd3c87c1c1265df407d3c7902faa07d409e6817deb7d58fdc0738bf0fd0dd19b44a9c18fea21b22481d06cf99e64c9f32e2bde7932d082fa9d1b1b4079c7af
7
+ data.tar.gz: e73c811e0b62e91a89dcc637aedade7ad997af774dc46fcf3604224654e0ce964ba222da623af9dc4b637512988de26db00f43b7f5ecf01f300db3b72b7c7a9f
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Adriano Tadao Sabadini Matsumoto
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ ###Git shortcut to automate the commit, squash and push commands
2
+
3
+ Sometimes execute the basic git commands is very boring and repetitive so, this shortcut is awesome. It will run these commands in this order:
4
+
5
+ - get the MERGE_BASE_ID
6
+ - `git reset --soft MERGE_BASE_ID`
7
+ - `git add .`
8
+ - `git commit -m "YOUR_MESSAGE_COMMIT"`
9
+ - `git push origin -f YOUR_CURRENT_BRANCH`
10
+
11
+ Warning: This procedures clears the commits history. So do not run it if you'll need this history.
12
+
13
+ **The Script is similar to:**
14
+
15
+ ```bash
16
+ #!/bin/bash
17
+
18
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
19
+ COMMIT_MESSAGE=$1
20
+ FROM_BRANCH=${2-master}
21
+ MERGE_BASE_ID=$(git merge-base HEAD $FROM_BRANCH)
22
+
23
+ echo -e "$(tput setaf 2)** Executing reset command$(tput sgr0)"
24
+ git reset --soft $MERGE_BASE_ID
25
+
26
+ echo -e "$(tput setaf 2)\n** Executing add command$(tput sgr0)\n"
27
+ git add .
28
+
29
+ echo -e "$(tput setaf 2)\n** Executing commit command$(tput sgr0)\n"
30
+ git commit -m "$COMMIT_MESSAGE"
31
+
32
+ echo -e "$(tput setaf 2)\n** Executing push command$(tput sgr0)\n"
33
+ git push origin -f $CURRENT_BRANCH
34
+ ```
35
+
36
+ **How to install:**
37
+
38
+ Run this command line:
39
+
40
+ ```bash
41
+ $ gem install git-squash
42
+ ```
43
+
44
+ **Usage:**
45
+
46
+ At some git repository, just run:
47
+
48
+ ```bash
49
+ git squash
50
+ ```
51
+
52
+ or
53
+
54
+ ```bash
55
+ git-squash "Commit Message"
56
+ ```
57
+
58
+ or
59
+
60
+ ```bash
61
+ git-squash "Commit Message" "branch_name_from_reset"
62
+ ```
data/bin/git-squash ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'git-squash'
4
+
5
+ GitSquash.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ class GitSquash
2
+ VERSION = "0.0.1"
3
+ end
data/lib/git-squash.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'colored'
2
+ require 'grit'
3
+ require 'git-squash/version'
4
+
5
+ class GitSquash
6
+ attr_accessor :argv
7
+
8
+ def run(argv)
9
+ @argv = argv
10
+ reset_command
11
+ add_command
12
+ commit_command
13
+ push_force_command
14
+ end
15
+
16
+ private
17
+
18
+ def push_force_command
19
+ puts "Executing push command".green
20
+ puts "git push origin -f #{ current_branch }".yellow
21
+ puts
22
+ %x(git push origin -f #{ current_branch })
23
+ end
24
+
25
+ def commit_command
26
+ puts "Executing commit command".green
27
+ puts "git commit -m #{ message }".yellow
28
+ puts
29
+ %x(git commit -m "#{ message }")
30
+ end
31
+
32
+ def add_command
33
+ puts "Executing add command".green
34
+ puts "git add .".yellow
35
+ puts
36
+ %x(git add .)
37
+ end
38
+
39
+ def reset_command
40
+ puts "Executing reset command from: #{ from_branch }".green
41
+ puts "git reset --soft #{ commit_id }".yellow
42
+ %x(git reset --soft #{ commit_id })
43
+ end
44
+
45
+ def commit_id
46
+ %x(git merge-base HEAD #{ from_branch })
47
+ end
48
+
49
+ def current_branch
50
+ @current_branch ||= repo.head.name
51
+ end
52
+
53
+ def repo
54
+ @repo ||= get_repo
55
+ end
56
+
57
+ def from_branch
58
+ @argv[1] || 'master'
59
+ end
60
+
61
+ def message
62
+ @argv[0] || 'no message commit'
63
+ end
64
+
65
+ def get_repo
66
+ repo_dir = `git rev-parse --show-toplevel`.chomp
67
+ begin
68
+ @repo = Grit::Repo.new(repo_dir)
69
+ rescue
70
+ raise "We don't seem to be in a git repository."
71
+ end
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-squash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adriano Tadao Sabadini Matsumoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colored
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: grit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.5.0
41
+ description: Sometimes execute the basic git commands is very boring and repetitive
42
+ so, this shortcut will make your git repository be most clean.
43
+ email: drianotadao@gmail.com
44
+ executables:
45
+ - git-squash
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - LICENSE
50
+ - README.md
51
+ - bin/git-squash
52
+ - lib/git-squash.rb
53
+ - lib/git-squash/version.rb
54
+ homepage: https://github.com/adrianotadao/git-squash
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.4.8
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: git shortcut to join all commits in just one
78
+ test_files: []