git_switch_branch 0.1.1 → 0.1.2
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.
data/lib/git_switch_branch.rb
CHANGED
@@ -12,13 +12,12 @@ module GitSwitchBranch
|
|
12
12
|
|
13
13
|
GSB_APP_DATA_DIR = '.git-switch-branch'
|
14
14
|
|
15
|
-
attr_accessor :git, :repo_changes_path
|
15
|
+
attr_accessor :git, :repo_changes_path
|
16
16
|
|
17
17
|
def self.initialize
|
18
18
|
@git = Git.open(Dir.pwd)
|
19
19
|
current_dir = File.basename(Dir.getwd)
|
20
20
|
@repo_changes_path = File.join(ENV['HOME'], GSB_APP_DATA_DIR, current_dir)
|
21
|
-
@patch_path = File.join(@repo_changes_path, @git.current_branch)
|
22
21
|
end
|
23
22
|
|
24
23
|
def self.find_and_checkout_branch(string)
|
@@ -35,6 +34,10 @@ module GitSwitchBranch
|
|
35
34
|
puts "Usage: gsb <branchname_or_part_of_branchname>"
|
36
35
|
end
|
37
36
|
|
37
|
+
def self.patch_path
|
38
|
+
File.join(@repo_changes_path, @git.current_branch)
|
39
|
+
end
|
40
|
+
|
38
41
|
private
|
39
42
|
|
40
43
|
def self.select_branch(string)
|
@@ -18,11 +18,11 @@ module GitSwitchBranch
|
|
18
18
|
return unless saved_changes?
|
19
19
|
puts "Restoring changes...".green
|
20
20
|
if apply_patch
|
21
|
-
File.delete(
|
21
|
+
File.delete(patch_path)
|
22
22
|
@git.reset
|
23
23
|
else
|
24
24
|
puts "Failed to restore saved changes!"
|
25
|
-
puts "Please check #{
|
25
|
+
puts "Please check #{patch_path}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -36,9 +36,9 @@ module GitSwitchBranch
|
|
36
36
|
|
37
37
|
def self.show_changes
|
38
38
|
if saved_changes?
|
39
|
-
system "cat #{
|
39
|
+
system "cat #{patch_path} | less"
|
40
40
|
else
|
41
|
-
puts "No saved changes found for this branch at #{
|
41
|
+
puts "No saved changes found for this branch at #{patch_path})"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -52,13 +52,13 @@ module GitSwitchBranch
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.save_stash_to_patch
|
55
|
-
puts "Saving stash to #{
|
56
|
-
system "git stash show -p > #{
|
55
|
+
puts "Saving stash to #{patch_path}"
|
56
|
+
system "git stash show -p > #{patch_path}"
|
57
57
|
system "git stash drop"
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.saved_changes?
|
61
|
-
File.exists?(
|
61
|
+
File.exists?(patch_path)
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.uncommitted_changes?
|
@@ -66,7 +66,7 @@ module GitSwitchBranch
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.apply_patch
|
69
|
-
system "patch -p1 < #{
|
69
|
+
system "patch -p1 < #{patch_path}"
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_switch_branch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: git
|
16
|
-
requirement: &
|
16
|
+
requirement: &70354603516120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.2.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70354603516120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colored
|
27
|
-
requirement: &
|
27
|
+
requirement: &70354603515660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70354603515660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: highline
|
38
|
-
requirement: &
|
38
|
+
requirement: &70354603515200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.6.15
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70354603515200
|
47
47
|
description: Easy git branch switching
|
48
48
|
email:
|
49
49
|
- daniel.eriksson@bukowskis.com
|