git_commands 3.3.0 → 3.3.1
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 +4 -4
- data/lib/git_commands/branch.rb +18 -9
- data/lib/git_commands/cli.rb +1 -1
- data/lib/git_commands/repository.rb +2 -0
- data/lib/git_commands/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d825f009ac0a426599aa2005c7e76d9c957965ff
|
4
|
+
data.tar.gz: ca49d614a2b5e61d56bf9ce10f01344b9e5e6813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d66feecb987428cf345fcd6e2592bc16c44fdd0369c308204f710094476145ee476f169aca17bf113b859670c7849154c1f855eeee0b1939e9e26b7639bdc8fe
|
7
|
+
data.tar.gz: f68c748c61ba79e29091640f83a87d87fc5dbe2cd325d4c83187ea8846406605f10a46fb83abc2714a8b022e8169030969ea8e37ad010123ebeff25a6de1c81d
|
data/lib/git_commands/branch.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
1
3
|
module GitCommands
|
4
|
+
using Colorize
|
2
5
|
class Branch
|
3
6
|
MASTER = "master"
|
4
7
|
ORIGIN = "origin/"
|
@@ -7,15 +10,9 @@ module GitCommands
|
|
7
10
|
name.strip.split(ORIGIN).last
|
8
11
|
end
|
9
12
|
|
10
|
-
def self.
|
11
|
-
|
12
|
-
|
13
|
-
end.select(&:valid?)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.by_file(names_file)
|
17
|
-
return [] unless File.file?(names_file)
|
18
|
-
File.foreach(names_file).map do |name|
|
13
|
+
def self.by_file(path)
|
14
|
+
return [] unless valid_path?(path)
|
15
|
+
File.foreach(path).map do |name|
|
19
16
|
new(name.strip)
|
20
17
|
end.select(&:valid?)
|
21
18
|
end
|
@@ -27,6 +24,12 @@ module GitCommands
|
|
27
24
|
end.reject(&:master?)
|
28
25
|
end
|
29
26
|
|
27
|
+
def self.by_names(names_list)
|
28
|
+
String(names_list).split(",").map do |name|
|
29
|
+
new(name.strip)
|
30
|
+
end.select(&:valid?)
|
31
|
+
end
|
32
|
+
|
30
33
|
def self.factory(src)
|
31
34
|
return [] unless src
|
32
35
|
branches = by_file(src)
|
@@ -35,6 +38,12 @@ module GitCommands
|
|
35
38
|
branches
|
36
39
|
end
|
37
40
|
|
41
|
+
def self.valid_path?(path)
|
42
|
+
path = Pathname.new(path)
|
43
|
+
warn "'#{path}' must be an absolute path!".red unless path.absolute?
|
44
|
+
path.absolute? && path.file?
|
45
|
+
end
|
46
|
+
|
38
47
|
attr_reader :name
|
39
48
|
|
40
49
|
def initialize(name)
|
data/lib/git_commands/cli.rb
CHANGED
@@ -22,7 +22,7 @@ module GitCommands
|
|
22
22
|
parser.parse!(@args)
|
23
23
|
computer = @computer_klass.new(repo: @repo, branches: @branches)
|
24
24
|
computer.send(@command_name)
|
25
|
-
rescue Computer::GitError, AbortError, Repository::InvalidError => e
|
25
|
+
rescue Repository::PathError, Computer::GitError, AbortError, Repository::InvalidError => e
|
26
26
|
error(e.message)
|
27
27
|
exit
|
28
28
|
end
|
@@ -4,10 +4,12 @@ module GitCommands
|
|
4
4
|
class Repository
|
5
5
|
LOCKING_FILES = %w(rebase-merge rebase-apply)
|
6
6
|
|
7
|
+
class PathError < ArgumentError; end
|
7
8
|
class InvalidError < StandardError; end
|
8
9
|
|
9
10
|
def initialize(path)
|
10
11
|
@path = Pathname::new(path.to_s)
|
12
|
+
fail PathError, "'#{path}' must be an absolute path!" unless @path.absolute?
|
11
13
|
fail InvalidError, "'#{path}' is not a valid GIT repository!" unless valid?
|
12
14
|
end
|
13
15
|
|
data/lib/git_commands/version.rb
CHANGED