ezgit 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +36 -29
- data/bin/eg +3 -0
- data/bin/ezgit +3 -0
- data/bin/gt +3 -0
- data/lib/ezgit/commands.rb +3 -6
- data/lib/ezgit/commands/clean.rb +15 -4
- data/lib/ezgit/commands/clone.rb +1 -1
- data/lib/ezgit/commands/commit.rb +1 -1
- data/lib/ezgit/commands/create.rb +1 -1
- data/lib/ezgit/commands/delete.rb +14 -4
- data/lib/ezgit/commands/goto.rb +14 -4
- data/lib/ezgit/commands/info.rb +2 -1
- data/lib/ezgit/commands/move.rb +1 -2
- data/lib/ezgit/commands/pull.rb +1 -1
- data/lib/ezgit/commands/push.rb +1 -1
- data/lib/ezgit/commands/reset.rb +15 -3
- data/lib/ezgit/commands/scrub.rb +21 -0
- data/lib/ezgit/commands/switch.rb +15 -3
- data/lib/ezgit/commands/tree.rb +3 -2
- data/lib/ezgit/{ez_command.rb → ezgit_command.rb} +9 -2
- data/lib/ezgit/{git.rb → processor.rb} +71 -60
- data/lib/ezgit/run.rb +8 -3
- data/lib/ezgit/string_no_color.rb +50 -0
- data/lib/ezgit/version.rb +1 -1
- metadata +14 -10
- data/bin/ez.bat +0 -2
- data/bin/wac.exe +0 -0
- data/lib/ezgit/commands/clean!.rb +0 -10
- data/lib/ezgit/commands/switch!.rb +0 -12
data/README.md
CHANGED
@@ -9,17 +9,19 @@
|
|
9
9
|
|
10
10
|
## DESCRIPTION
|
11
11
|
|
12
|
-
|
12
|
+
I like the Git source control system. It's truly awesome. And like the first time you disassembled your dad's VCR only to be stumped by all those gears and wires, Git probably gave you a bit of a brain-bending whirl when you first looked at it too. There is so much that Git can do, but only so little that you really need it to do. **EZGit** wants to help.
|
13
13
|
|
14
|
-
EZGit
|
15
|
-
* _**Where do branches live? On my local machine or on the remote?**_ Who cares? EZGit handles it for you.
|
16
|
-
* _**What's the difference between the working directory, the stage(or index), and the local repo?**_ I could spend hours explaining it to you, but if you don't really want to know, EZGit is here to make that stuff go away.
|
14
|
+
EZGit is a command-line interface written in Ruby and distributed as a gem. **The goal of EZGit** is to simplify your daily source control use cases without the need to fully gaze upon the complex beauty that is Git. With EZGit, committers with any level of Git knowledge can work in the repo with confidence and consistency.
|
17
15
|
|
18
|
-
EZGit
|
16
|
+
EZGit abstracts away many Git concepts that are consistent sources of confusion. Concepts such as...
|
17
|
+
* _**Where do branches live? On my local machine or on the remote?**_ Who cares? EZGit handles it for you.
|
18
|
+
* _**What's the difference between the working directory, the stage(or index), and the local repo?**_ I could spend hours explaining it to you, but if you don't really want to know, EZGit is here to make those confusing thoughts go away.
|
19
|
+
* _**When would I need to do a 'git reset --hard', as opposed to '--soft' or '--mixed'?**_ If you're asking about staging files, stop thinking about that. You have better things to do. Just make your files and folders look the way you want and EZGit will take care of the rest.
|
20
|
+
* _**But I'm confused about the differences between git checkout, reset, revert, and other commands. Do some of these do more than one thing??**_ I know. I hear your pain. That's why EZGit replaces git's complex and overloaded commands with simple, clean, intentional, ruby-styled names. If any single git command has multiple, yet different _common_ uses, rest assured that EZGit provides an unique, easy-to-understand command for that task.
|
19
21
|
|
20
|
-
In future
|
22
|
+
Ready to try, EZGit? Hold on, Cowboy. It ain't done yet. Go ahead and use it, but be sure to check back often for updates. In the future, EZGit will implement a branching strategy that has been honed and refined over the last two years by a large agile enterprise development shop. The concepts of merging (and rebasing) will be equally simplified so that you can concentrate on your code, and not on, "how the heck do I rebase and then --no-ff merge my changes?!" And, hey, while you're checking things out, drop an occasional line if you find a bug. That'd be nice.
|
21
23
|
|
22
|
-
Best of all, EZGit is still Git. So if you are a Git-Fu master, you can go back to using your favorite
|
24
|
+
Best of all, EZGit is still Git. So if you are a Git-Fu master, you can always go back to using your favorite overloaded Git commands at any time. They'll always be there waiting for you at those times when you absolutely need to cherry-pick your fixes from branchB onto branchA, interactively rebase & squash directly from branchC in your buddy's repo, and finally, ours-merge them into master ...or other stuff like that.
|
23
25
|
|
24
26
|
If you try EZGit and find that it doesn't quite work for you, drop me a line and let me know why. I'm happy to look at other use cases and consider including them in future updates.
|
25
27
|
|
@@ -43,38 +45,43 @@ EZGit changes a lot (especially during this development phase). To update your e
|
|
43
45
|
|
44
46
|
Once installed, take a look at the help menu:
|
45
47
|
|
46
|
-
|
48
|
+
ezgit -h
|
47
49
|
|
48
50
|
|
49
51
|
EZGit is a simple interface for working with git repositories.
|
50
52
|
|
51
53
|
Usage:
|
54
|
+
ezgit [<options>] <commands>
|
55
|
+
- or -
|
52
56
|
ez [<options>] <commands>
|
57
|
+
- or -
|
58
|
+
eg [<options>] <commands>
|
59
|
+
- or -
|
60
|
+
gt [<options>] <commands>
|
53
61
|
|
54
62
|
commands are:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
update Attempts to self-update from rubygems.org.
|
63
|
+
clean Wipes untracked files unless they are marked as ignored(via .gitignore).
|
64
|
+
clone Creates a copy of a repository.
|
65
|
+
commit Creates a commit for all current file changes.
|
66
|
+
create Create a new branch in the current state.
|
67
|
+
delete Completely delete a given branch, both locally and on the remote.
|
68
|
+
goto Move to the location in the tree specified by a commit id. All changes will be lost.
|
69
|
+
info Shows files status and current branches.
|
70
|
+
move Switch and move changes to the given branch.
|
71
|
+
pull Pulls the latest changes from the remote.
|
72
|
+
push Pushes the current branch changes to the remote.
|
73
|
+
reset Deletes changes in all tracked files. Untracked files will not be affected.
|
74
|
+
scrub Wipes untracked files including ignored files.
|
75
|
+
switch Abandon all changes and switch to the given branch.
|
76
|
+
tree Shows git tree history for the current branch
|
77
|
+
update Attempts to self-update from rubygems.org.
|
71
78
|
|
72
79
|
options are:
|
73
|
-
--dry-run
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
80
|
+
--dry-run, -n: Makes all commands passive.
|
81
|
+
--force, -f: Forces all prompting off. Use ! at end of command name to do the same.
|
82
|
+
--debug, -d: Shows command level debug info.
|
83
|
+
--version, -v: Print version and exit
|
84
|
+
--help, -h: Show this message
|
78
85
|
|
79
86
|
## EXAMPLE
|
80
87
|
|
data/bin/eg
ADDED
data/bin/ezgit
ADDED
data/bin/gt
ADDED
data/lib/ezgit/commands.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
require 'ezgit/git'
|
2
|
-
|
3
1
|
class Commands
|
4
2
|
|
5
|
-
attr_accessor :all, :symbols, :names, :help_list, :options
|
3
|
+
attr_accessor :all, :symbols, :names, :help_list, :options
|
6
4
|
|
7
5
|
|
8
6
|
def initialize
|
@@ -28,7 +26,6 @@ class Commands
|
|
28
26
|
|
29
27
|
|
30
28
|
def process
|
31
|
-
@git = Git.new(@options)
|
32
29
|
@cmd = ARGV.shift
|
33
30
|
matched = false
|
34
31
|
@all.each do |current|
|
@@ -36,9 +33,9 @@ class Commands
|
|
36
33
|
matched = true
|
37
34
|
@cmd_opts = Trollop::options do
|
38
35
|
usage = current[:usage]
|
39
|
-
usage ||= "
|
36
|
+
usage ||= "ezgit #{current[:name].to_s} [<options>]"
|
40
37
|
banner <<-HELP_DESCRIPTION
|
41
|
-
command:
|
38
|
+
command: ezgit #{current[:name].to_s}\n
|
42
39
|
#{current[:help].to_s}
|
43
40
|
|
44
41
|
Usage:
|
data/lib/ezgit/commands/clean.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
$commands.all << {
|
2
|
-
name: 'clean',
|
3
|
-
help: '
|
2
|
+
name: 'clean!',
|
3
|
+
help: 'Bypasses the prompt.',
|
4
|
+
usage: '',
|
4
5
|
options: [
|
5
|
-
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f']
|
6
|
+
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f', default: true]
|
6
7
|
],
|
7
8
|
action: lambda do |opts, args|
|
8
|
-
|
9
|
+
Processor.new(opts).clean!(false)
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
$commands.all << {
|
14
|
+
name: 'clean',
|
15
|
+
help: 'Wipes untracked files unless they are marked as ignored(via .gitignore).',
|
16
|
+
usage: '',
|
17
|
+
options: [],
|
18
|
+
action: lambda do |opts, args|
|
19
|
+
Processor.new(opts).clean!(false)
|
9
20
|
end
|
10
21
|
}
|
data/lib/ezgit/commands/clone.rb
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
$commands.all << {
|
2
2
|
name: 'delete!',
|
3
|
-
help: '
|
4
|
-
usage: '
|
3
|
+
help: 'Bypasses the prompt.',
|
4
|
+
usage: '',
|
5
5
|
options: [
|
6
|
-
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f']
|
6
|
+
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f', default: true]
|
7
7
|
],
|
8
8
|
action: lambda do |opts, args|
|
9
|
-
|
9
|
+
Processor.new(opts).delete!(args)
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
$commands.all << {
|
14
|
+
name: 'delete',
|
15
|
+
help: 'Completely delete a given branch, both locally and on the remote.',
|
16
|
+
usage: 'ez delete <branch_name>',
|
17
|
+
options: [],
|
18
|
+
action: lambda do |opts, args|
|
19
|
+
Processor.new(opts).delete!(args)
|
10
20
|
end
|
11
21
|
}
|
data/lib/ezgit/commands/goto.rb
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
$commands.all << {
|
2
2
|
name: 'goto!',
|
3
|
-
help: '
|
4
|
-
usage: '
|
3
|
+
help: 'Bypasses the prompt.',
|
4
|
+
usage: '',
|
5
5
|
options: [
|
6
|
-
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f']
|
6
|
+
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f', default: true]
|
7
7
|
],
|
8
8
|
action: lambda do |opts, args|
|
9
|
-
|
9
|
+
Processor.new(opts).goto!(args)
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
$commands.all << {
|
14
|
+
name: 'goto',
|
15
|
+
help: 'Move to the location in the tree specified by a commit id. All changes will be lost.',
|
16
|
+
usage: 'ez goto <commit>',
|
17
|
+
options: [],
|
18
|
+
action: lambda do |opts, args|
|
19
|
+
Processor.new(opts).goto!(args)
|
10
20
|
end
|
11
21
|
}
|
data/lib/ezgit/commands/info.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
$commands.all << {
|
2
2
|
name: 'info',
|
3
3
|
help: 'Shows files status and current branches.',
|
4
|
+
usage: '',
|
4
5
|
options: [
|
5
6
|
[:ignored, 'Lists the files are being ignored.', short: '-i']
|
6
7
|
],
|
7
8
|
action: lambda do |opts, args|
|
8
|
-
|
9
|
+
Processor.new(opts).info
|
9
10
|
end
|
10
11
|
}
|
data/lib/ezgit/commands/move.rb
CHANGED
data/lib/ezgit/commands/pull.rb
CHANGED
data/lib/ezgit/commands/push.rb
CHANGED
data/lib/ezgit/commands/reset.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
$commands.all << {
|
2
2
|
name: 'reset!',
|
3
|
-
help: '
|
3
|
+
help: 'Bypasses the prompt.',
|
4
|
+
usage: '',
|
4
5
|
options: [
|
5
|
-
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f']
|
6
|
+
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f', default: true]
|
6
7
|
],
|
7
8
|
action: lambda do |opts, args|
|
8
|
-
|
9
|
+
Processor.new(opts).reset_hard!
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
|
14
|
+
$commands.all << {
|
15
|
+
name: 'reset',
|
16
|
+
help: 'Deletes changes in all tracked files. Untracked files will not be affected.',
|
17
|
+
usage: '',
|
18
|
+
options: [],
|
19
|
+
action: lambda do |opts, args|
|
20
|
+
Processor.new(opts).reset_hard!
|
9
21
|
end
|
10
22
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ezgit/processor'
|
2
|
+
|
3
|
+
$commands.all << {
|
4
|
+
name: 'scrub!',
|
5
|
+
help: 'Bypasses the prompt.',
|
6
|
+
options: [
|
7
|
+
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f', default: true]
|
8
|
+
],
|
9
|
+
action: lambda do |opts, args|
|
10
|
+
Processor.new(opts).clean!(true)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
$commands.all << {
|
15
|
+
name: 'scrub',
|
16
|
+
help: 'Wipes untracked files including ignored files.',
|
17
|
+
options: [],
|
18
|
+
action: lambda do |opts, args|
|
19
|
+
Processor.new(opts).clean!(true)
|
20
|
+
end
|
21
|
+
}
|
@@ -1,10 +1,22 @@
|
|
1
|
+
$commands.all << {
|
2
|
+
name: 'switch!',
|
3
|
+
help: 'Abandon all changes and switch to the given branch.',
|
4
|
+
usage: '',
|
5
|
+
options: [
|
6
|
+
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f', default: true]
|
7
|
+
],
|
8
|
+
action: lambda do |opts, args|
|
9
|
+
Processor.new(opts).switch!('switch!', args)
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
|
1
14
|
$commands.all << {
|
2
15
|
name: 'switch',
|
3
|
-
help: '
|
16
|
+
help: 'Abandon all changes and switch to the given branch.',
|
4
17
|
usage: 'ez switch <branch_name>',
|
5
18
|
options: [],
|
6
19
|
action: lambda do |opts, args|
|
7
|
-
opts
|
8
|
-
$commands.git.switch!(opts,args)
|
20
|
+
Processor.new(opts).switch!('switch!', args)
|
9
21
|
end
|
10
22
|
}
|
data/lib/ezgit/commands/tree.rb
CHANGED
@@ -7,7 +7,8 @@ $commands.all << {
|
|
7
7
|
[:number, 'Number of entries to display.', short: '-n', default:20]
|
8
8
|
],
|
9
9
|
action: lambda do |opts, args|
|
10
|
-
count =
|
11
|
-
|
10
|
+
count = opts[:number]
|
11
|
+
show_all = !opts[:current]
|
12
|
+
Processor.new(opts).display_log_graph(count, show_all)
|
12
13
|
end
|
13
14
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'ezgit/version'
|
2
2
|
|
3
|
-
class
|
3
|
+
class EzgitCommand
|
4
4
|
def self.options(subcommand_names, subcommand_help_list)
|
5
5
|
return Trollop::options do
|
6
6
|
version Ezgit::VERSION
|
@@ -8,13 +8,20 @@ class EzCommand
|
|
8
8
|
EZGit is a simple interface for working with git repositories.
|
9
9
|
|
10
10
|
Usage:
|
11
|
+
ezgit [<options>] <commands>
|
12
|
+
- or -
|
11
13
|
ez [<options>] <commands>
|
14
|
+
- or -
|
15
|
+
eg [<options>] <commands>
|
16
|
+
- or -
|
17
|
+
gt [<options>] <commands>
|
12
18
|
|
13
19
|
commands are:
|
14
20
|
#{subcommand_help_list}
|
15
21
|
options are:
|
16
22
|
HELP_DESCRIPTION
|
17
|
-
opt :
|
23
|
+
opt :dry_run, 'Makes all commands passive.', short: '-n'
|
24
|
+
opt :force, 'Forces all prompting off. Use ! at end of command name to do the same.', short: '-f', default: false
|
18
25
|
opt :debug, 'Shows command level debug info.', short: '-d'
|
19
26
|
stop_on subcommand_names
|
20
27
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'open3'
|
2
2
|
|
3
|
-
class
|
3
|
+
class Processor
|
4
4
|
|
5
|
-
attr_reader :current_branch, :remote_branch, :all_branches, :all_uniq_branches
|
5
|
+
attr_reader :current_branch, :remote_branch, :all_branches, :all_uniq_branches, :no_prompt, :dry_run, :dry_run_flag
|
6
6
|
NO_BRANCH = '(nobranch)'
|
7
7
|
|
8
8
|
|
9
9
|
def initialize(global_options)
|
10
|
-
@
|
11
|
-
@dry_run_flag = @
|
10
|
+
@dry_run = global_options[:dry_run]
|
11
|
+
@dry_run_flag = @dry_run ? '-n' : ''
|
12
|
+
@no_prompt = global_options[:force]
|
12
13
|
end
|
13
14
|
|
14
15
|
|
@@ -74,9 +75,9 @@ class Git
|
|
74
75
|
|
75
76
|
def display_log_graph(count = 5, show_all = false)
|
76
77
|
puts ''
|
77
|
-
puts "REPOSITORY TREE".
|
78
|
+
puts "REPOSITORY TREE".bold + "(last #{count} commits)"
|
78
79
|
all = show_all ? '--all' : ''
|
79
|
-
stdin, stdout, stderr = Open3.popen3("git log --graph #{all} --format=format:\"#{CYAN}%h #{CLEAR + CYAN}(%cr) #{CYAN}%cn #{CLEAR
|
80
|
+
stdin, stdout, stderr = Open3.popen3("git log --graph #{all} --format=format:\"#{CYAN}%h #{CLEAR + CYAN}(%cr) #{CYAN}%cn #{CLEAR}%s#{CYAN + BOLD}%d#{CLEAR}\" --abbrev-commit --date=relative -n #{count}")
|
80
81
|
err = stderr.readlines
|
81
82
|
return puts 'There is no history yet.'.cyan.bold if err.any?
|
82
83
|
puts err.join('') + stdout.readlines.join('')
|
@@ -96,12 +97,12 @@ class Git
|
|
96
97
|
end
|
97
98
|
|
98
99
|
|
99
|
-
def info
|
100
|
+
def info
|
100
101
|
puts '________________________________'
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
display_log_graph
|
103
|
+
display_branch_list_with_current
|
104
|
+
display_current_changes
|
105
|
+
display_sync_status
|
105
106
|
puts '________________________________'
|
106
107
|
end
|
107
108
|
|
@@ -133,29 +134,29 @@ class Git
|
|
133
134
|
|
134
135
|
def display_sync_status
|
135
136
|
puts ''
|
136
|
-
puts ' SYNC STATUS:'.
|
137
|
+
puts ' SYNC STATUS:'.bold
|
137
138
|
stat, count = check_remote_status
|
138
139
|
commit_s = (count == 1) ? 'commit' : 'commits'
|
139
140
|
case stat
|
140
141
|
when :ahead
|
141
142
|
puts " Your #{current_branch.bold + CYAN} branch is ahead of the remote by #{count} #{commit_s}.".cyan
|
142
|
-
puts " (Use '
|
143
|
+
puts " (Use 'ezgit pull' to update the remote.)".cyan
|
143
144
|
when :behind
|
144
145
|
puts " Your #{current_branch.bold + YELLOW} branch is behind the remote by #{count} #{commit_s}.".yellow
|
145
|
-
puts " (Use '
|
146
|
+
puts " (Use 'ezgit pull' to get the new changes.)".yellow
|
146
147
|
when :rebase
|
147
148
|
puts " Your #{current_branch} branch has diverged #{count} #{commit_s} from the remote.".red.bold
|
148
149
|
puts " (Use must use git directly to put them back in sync.)".red.bold
|
149
150
|
when :no_remote
|
150
151
|
puts " Your #{current_branch.bold + CYAN} branch does not yet exist on the remote.".cyan
|
151
|
-
puts " (Use '
|
152
|
+
puts " (Use 'ezgit pull' to update the remote.)".cyan
|
152
153
|
when :headless
|
153
154
|
puts " You are in a headless state (not on a branch)".red.bold
|
154
|
-
puts " (Use '
|
155
|
-
puts " or use '
|
155
|
+
puts " (Use 'ezgit create <branch>' to create a branch at this commit,".red.bold
|
156
|
+
puts " or use 'ezgit switch <branch>' to switch to a branch.)".red.bold
|
156
157
|
else
|
157
158
|
puts " Your #{current_branch.bold + GREEN} branch is in sync with the remote.".green
|
158
|
-
puts " (Use '
|
159
|
+
puts " (Use 'ezgit pull' to ensure it stays in sync.)".green
|
159
160
|
end
|
160
161
|
end
|
161
162
|
|
@@ -171,7 +172,7 @@ class Git
|
|
171
172
|
|
172
173
|
def display_current_changes(opts = nil)
|
173
174
|
puts ''
|
174
|
-
puts " TO BE COMMITTED ON: #{current_branch}".
|
175
|
+
puts " TO BE COMMITTED ON: #{current_branch}".bold
|
175
176
|
has_changes, changes = check_local_changes(opts)
|
176
177
|
puts " No changes.".green unless has_changes
|
177
178
|
changes.collect! { |line|
|
@@ -189,23 +190,22 @@ class Git
|
|
189
190
|
|
190
191
|
def clone(args)
|
191
192
|
return puts 'invalid number of arguments. Requires a source. (Destination is optional.)' if args.count < 1 || args.count > 2
|
192
|
-
return if @
|
193
|
+
return if @dry_run
|
193
194
|
puts out = `git clone #{args.first} #{args[1]}`
|
194
195
|
repo_name = args[1] || out.split('\'')[1]
|
195
196
|
puts 'You have created a copy of ' + args.first.to_s.bold + ' in the ' + repo_name.bold + ' directory.' if $? == 0
|
196
197
|
end
|
197
198
|
|
198
199
|
|
199
|
-
def clean!(wipe_ignored
|
200
|
-
|
201
|
-
|
202
|
-
out =
|
203
|
-
err
|
204
|
-
puts err.red.bold unless opts[:force]
|
200
|
+
def clean!(wipe_ignored)
|
201
|
+
command = 'git clean -df'
|
202
|
+
command += 'x' if wipe_ignored
|
203
|
+
out, err = call_command_with_out_error(command + 'n')
|
204
|
+
puts err.red.bold unless no_prompt
|
205
205
|
return puts 'Nothing to clean.'.green if err.empty?
|
206
|
-
return if
|
207
|
-
|
208
|
-
puts
|
206
|
+
return if dry_run
|
207
|
+
run_lambda_with_prompt do
|
208
|
+
puts `#{command}`
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
@@ -223,48 +223,48 @@ class Git
|
|
223
223
|
end
|
224
224
|
|
225
225
|
|
226
|
-
def
|
227
|
-
unless
|
228
|
-
|
226
|
+
def run_lambda_with_prompt(opts = nil)
|
227
|
+
unless no_prompt
|
228
|
+
puts 'proceed(y/n)? '.bold
|
229
229
|
return unless prompt_for_y_n
|
230
230
|
end
|
231
231
|
yield
|
232
232
|
end
|
233
233
|
|
234
234
|
|
235
|
-
def reset_hard!
|
236
|
-
return if @
|
237
|
-
puts 'All changes in tracked files will be lost.'.red.bold unless
|
238
|
-
|
235
|
+
def reset_hard!
|
236
|
+
return if @dry_run
|
237
|
+
puts 'All changes in tracked files will be lost.'.red.bold unless no_prompt
|
238
|
+
run_lambda_with_prompt do
|
239
239
|
puts `git reset --hard`
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
243
243
|
|
244
|
-
def goto!(
|
244
|
+
def goto!(args)
|
245
245
|
return puts "Please specify a commit id.".yellow.bold if args.count < 1
|
246
246
|
return puts "Invalid number of arguments. Please specify only a commit id.".yellow.bold if args.count > 1
|
247
247
|
commit_id = args[0].to_s
|
248
|
-
return puts "Would go to #{commit_id}" if
|
249
|
-
puts "About to go to #{commit_id}. All changes in tracked files will be lost.".red.bold unless
|
250
|
-
|
248
|
+
return puts "Would go to #{commit_id}" if dry_run
|
249
|
+
puts "About to go to #{commit_id}. All changes in tracked files will be lost.".red.bold unless no_prompt
|
250
|
+
run_lambda_with_prompt do
|
251
251
|
puts `git reset --hard #{commit_id}`
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
255
255
|
|
256
|
-
def create(
|
257
|
-
return puts
|
258
|
-
return puts
|
256
|
+
def create(args)
|
257
|
+
return puts 'Please specify a branch name.'.yellow.bold if args.count < 1
|
258
|
+
return puts 'Invalid number of arguments. Please specify only a branch name.'.yellow.bold if args.count > 1
|
259
259
|
branch_name = args[0].to_s
|
260
|
-
return puts "Would create branch: #{branch_name}" if
|
260
|
+
return puts "Would create branch: #{branch_name}" if dry_run
|
261
261
|
`git checkout -b #{branch_name}`
|
262
262
|
display_branch_list_with_current
|
263
263
|
display_current_changes
|
264
264
|
end
|
265
265
|
|
266
266
|
|
267
|
-
def delete!(
|
267
|
+
def delete!(args)
|
268
268
|
return puts "Please specify a branch name.".yellow.bold if args.count < 1
|
269
269
|
return puts "Invalid number of arguments. Please specify only a branch name.".yellow.bold if args.count > 1
|
270
270
|
branch_name = args[0].to_s
|
@@ -278,9 +278,9 @@ class Git
|
|
278
278
|
branches << remote_name if is_remote
|
279
279
|
return puts "Cannot delete ".red + branch_name.red.bold + " while you are using it. Please switch to another branch and try again.".red if branches.include?(current_branch)
|
280
280
|
return puts "Branch does not exist: ".red + branch_name.red.bold unless branches.any?
|
281
|
-
return puts "Would completely delete branches: #{branches.join(',')}" if @
|
282
|
-
print " Are you sure you want to delete '#{branch_name}'(y/n)?".red.bold
|
283
|
-
return unless
|
281
|
+
return puts "Would completely delete branches: #{branches.join(',')}" if @dry_run
|
282
|
+
print " Are you sure you want to delete '#{branch_name}'(y/n)?".red.bold unless no_prompt
|
283
|
+
return unless run_lambda_with_prompt do
|
284
284
|
puts `git push --delete #{remote_name.sub('/', ' ')}` if is_remote
|
285
285
|
puts `git branch -D #{branch_name}` if is_local
|
286
286
|
refresh_branches
|
@@ -293,7 +293,7 @@ class Git
|
|
293
293
|
# :switch - switch if there are not changes. Otherwise halt!
|
294
294
|
# :switch! - clobber all files before switching
|
295
295
|
# :move - move files with switch
|
296
|
-
def switch!(
|
296
|
+
def switch!(mode, args)
|
297
297
|
return puts "Please specify a branch name.".yellow.bold if args.count < 1
|
298
298
|
return puts "Invalid number of arguments. Please specify only a branch name.".yellow.bold if args.count > 1
|
299
299
|
branch_name = args[0].to_s
|
@@ -301,28 +301,28 @@ class Git
|
|
301
301
|
return puts "Already on branch: #{current_branch.bold}".green if current_branch.eql?(branch_name)
|
302
302
|
has_changes, changes = check_local_changes
|
303
303
|
#move files with switch
|
304
|
-
if
|
304
|
+
if mode == 'move'
|
305
305
|
x = `git checkout #{branch_name}`
|
306
306
|
return
|
307
307
|
end
|
308
308
|
#switch if there are not changes. Otherwise halt!
|
309
|
-
if has_changes &&
|
309
|
+
if has_changes && mode == 'switch'
|
310
310
|
display_current_changes
|
311
311
|
puts " Cannot switch branches when you have unresolved changes".red
|
312
|
-
puts " Use ".red + "'
|
313
|
-
puts " or use ".red + "'
|
312
|
+
puts " Use ".red + "'ezgit switch! <branch>'".red.bold + " to abandon your changes and switch anyway,".red
|
313
|
+
puts " or use ".red + "'ezgit move <branch>'".red.bold + " to move your changes and switch.".red
|
314
314
|
return
|
315
315
|
end
|
316
316
|
#clobber all files before switching
|
317
317
|
#respect the -f option
|
318
|
-
if has_changes &&
|
319
|
-
unless
|
318
|
+
if has_changes && mode == 'switch!'
|
319
|
+
unless no_prompt
|
320
320
|
display_current_changes
|
321
321
|
puts ''
|
322
322
|
print " WARNING: You may lose changes if you switch branches without committing.".red.bold
|
323
323
|
end
|
324
|
-
return unless
|
325
|
-
|
324
|
+
return unless run_lambda_with_prompt do
|
325
|
+
@no_prompt = true
|
326
326
|
x = `git clean -df`
|
327
327
|
x = `git checkout -f #{branch_name}`
|
328
328
|
return
|
@@ -356,7 +356,7 @@ class Git
|
|
356
356
|
stat, count = check_remote_status
|
357
357
|
case stat
|
358
358
|
when :rebase
|
359
|
-
if @
|
359
|
+
if @dry_run
|
360
360
|
puts 'would merge changes'
|
361
361
|
display_sync_status
|
362
362
|
return
|
@@ -365,7 +365,7 @@ class Git
|
|
365
365
|
#TODO: CONFLICT HANDLING?
|
366
366
|
puts 'TODO: CONFLICT HANDLING?'
|
367
367
|
when :behind
|
368
|
-
if @
|
368
|
+
if @dry_run
|
369
369
|
puts "would reset branch to #{remote_branch}"
|
370
370
|
display_sync_status
|
371
371
|
return
|
@@ -384,9 +384,10 @@ class Git
|
|
384
384
|
stat, count = check_remote_status
|
385
385
|
if stat.eql?(:rebase) || stat.eql?(:behind)
|
386
386
|
puts " The remote has been updated since you began this sync.".yellow.bold
|
387
|
-
puts " Try running '
|
387
|
+
puts " Try running 'ezgit pull' again".yellow.bold
|
388
388
|
elsif stat.eql?(:no_remote) || stat.eql?(:ahead)
|
389
389
|
puts `git push -u #{remote_branch.sub('/', ' ')}`
|
390
|
+
refresh_branches
|
390
391
|
elsif stat.eql?(:headless)
|
391
392
|
puts ' You cannot push unless you are on a branch.'.red.bold
|
392
393
|
else
|
@@ -396,4 +397,14 @@ class Git
|
|
396
397
|
end
|
397
398
|
|
398
399
|
|
400
|
+
private
|
401
|
+
|
402
|
+
|
403
|
+
def call_command_with_out_error(command)
|
404
|
+
stdin, stdout, stderr = Open3.popen3(command)
|
405
|
+
out = stderr.readlines.join('')
|
406
|
+
err = stdout.readlines.join('')
|
407
|
+
return out, err
|
408
|
+
end
|
409
|
+
|
399
410
|
end
|
data/lib/ezgit/run.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
|
1
|
+
if RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /mingw32/
|
2
|
+
require 'ezgit/string_no_color'
|
3
|
+
else
|
4
|
+
require 'ezgit/string'
|
5
|
+
end
|
6
|
+
|
2
7
|
require 'ezgit/trollop'
|
3
8
|
require 'ezgit/commands'
|
4
|
-
require 'ezgit/
|
9
|
+
require 'ezgit/ezgit_command'
|
5
10
|
|
6
11
|
$commands = Commands.new
|
7
12
|
$commands.read
|
8
|
-
$commands.options =
|
13
|
+
$commands.options = EzgitCommand::options($commands.names, $commands.help_list)
|
9
14
|
$commands.process
|
@@ -0,0 +1,50 @@
|
|
1
|
+
CLEAR = ''
|
2
|
+
BOLD = ''
|
3
|
+
BLACK = ''
|
4
|
+
GREEN = ''
|
5
|
+
RED = ''
|
6
|
+
YELLOW = ''
|
7
|
+
BLUE = ''
|
8
|
+
MAGENTA = ''
|
9
|
+
CYAN = ''
|
10
|
+
WHITE = ''
|
11
|
+
|
12
|
+
class String
|
13
|
+
|
14
|
+
def bold
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def black
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def red
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def green
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def yellow
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def blue
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def magenta
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def cyan
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def white
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/lib/ezgit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,16 +9,18 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: EZGit is a simple interface for working with git repositories
|
15
15
|
email: ajjames@msn.com
|
16
16
|
executables:
|
17
|
+
- ezgit
|
17
18
|
- ez
|
19
|
+
- eg
|
20
|
+
- gt
|
18
21
|
extensions: []
|
19
22
|
extra_rdoc_files: []
|
20
23
|
files:
|
21
|
-
- lib/ezgit/commands/clean!.rb
|
22
24
|
- lib/ezgit/commands/clean.rb
|
23
25
|
- lib/ezgit/commands/clone.rb
|
24
26
|
- lib/ezgit/commands/commit.rb
|
@@ -30,21 +32,23 @@ files:
|
|
30
32
|
- lib/ezgit/commands/pull.rb
|
31
33
|
- lib/ezgit/commands/push.rb
|
32
34
|
- lib/ezgit/commands/reset.rb
|
33
|
-
- lib/ezgit/commands/
|
35
|
+
- lib/ezgit/commands/scrub.rb
|
34
36
|
- lib/ezgit/commands/switch.rb
|
35
37
|
- lib/ezgit/commands/tree.rb
|
36
38
|
- lib/ezgit/commands/update.rb
|
37
39
|
- lib/ezgit/commands.rb
|
38
|
-
- lib/ezgit/
|
39
|
-
- lib/ezgit/
|
40
|
+
- lib/ezgit/ezgit_command.rb
|
41
|
+
- lib/ezgit/processor.rb
|
40
42
|
- lib/ezgit/run.rb
|
41
43
|
- lib/ezgit/string.rb
|
44
|
+
- lib/ezgit/string_no_color.rb
|
42
45
|
- lib/ezgit/trollop.rb
|
43
46
|
- lib/ezgit/version.rb
|
44
47
|
- lib/ezgit.rb
|
48
|
+
- bin/eg
|
45
49
|
- bin/ez
|
46
|
-
- bin/
|
47
|
-
- bin/
|
50
|
+
- bin/ezgit
|
51
|
+
- bin/gt
|
48
52
|
- README.md
|
49
53
|
homepage: http://github.com/ajjames/ezgit
|
50
54
|
licenses:
|
@@ -56,13 +60,13 @@ require_paths:
|
|
56
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
61
|
none: false
|
58
62
|
requirements:
|
59
|
-
- -
|
63
|
+
- - ">="
|
60
64
|
- !ruby/object:Gem::Version
|
61
65
|
version: '0'
|
62
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
67
|
none: false
|
64
68
|
requirements:
|
65
|
-
- -
|
69
|
+
- - ">="
|
66
70
|
- !ruby/object:Gem::Version
|
67
71
|
version: '0'
|
68
72
|
requirements: []
|
data/bin/ez.bat
DELETED
data/bin/wac.exe
DELETED
Binary file
|
@@ -1,10 +0,0 @@
|
|
1
|
-
$commands.all << {
|
2
|
-
name: 'clean!',
|
3
|
-
help: 'Wipes all untracked and ignored files.',
|
4
|
-
options: [
|
5
|
-
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f']
|
6
|
-
],
|
7
|
-
action: lambda do |opts, args|
|
8
|
-
$commands.git.clean!(true, opts)
|
9
|
-
end
|
10
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
$commands.all << {
|
2
|
-
name: 'switch!',
|
3
|
-
help: 'Abandon all changes and switch to the given branch.',
|
4
|
-
usage: 'ez switch! <branch_name>',
|
5
|
-
options: [
|
6
|
-
[:force, 'Automatically approve and bypass the confirmation prompt.', short: '-f']
|
7
|
-
],
|
8
|
-
action: lambda do |opts, args|
|
9
|
-
opts[:switch!] = true
|
10
|
-
$commands.git.switch!(opts, args)
|
11
|
-
end
|
12
|
-
}
|