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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4794d0456217191d8939a0bf9c547221176e6ecb
4
- data.tar.gz: ddb26bbffe05ef5ec8f997f889aded4fee03201b
3
+ metadata.gz: d825f009ac0a426599aa2005c7e76d9c957965ff
4
+ data.tar.gz: ca49d614a2b5e61d56bf9ce10f01344b9e5e6813
5
5
  SHA512:
6
- metadata.gz: b6d7669adc0eacc64866b606b5f1aa7a437708ed4f7ddb78a15d13a46bbabfddda4d7c75869bbaa47f1f378c8ab66ed336ffa798d59b32b970fd60010b26a545
7
- data.tar.gz: e850c3d49d5ed95020bfc5bebaff07ef91aabb968c88d615cd76f7421c89cb51b7dd28e6cca61e731a08288e8e4a02ed112bf0b24a87f8cfb48e5ba5422121a8
6
+ metadata.gz: d66feecb987428cf345fcd6e2592bc16c44fdd0369c308204f710094476145ee476f169aca17bf113b859670c7849154c1f855eeee0b1939e9e26b7639bdc8fe
7
+ data.tar.gz: f68c748c61ba79e29091640f83a87d87fc5dbe2cd325d4c83187ea8846406605f10a46fb83abc2714a8b022e8169030969ea8e37ad010123ebeff25a6de1c81d
@@ -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.by_names(names_list)
11
- String(names_list).split(",").map do |name|
12
- new(name.strip)
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)
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module GitCommands
2
- VERSION = "3.3.0"
2
+ VERSION = "3.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob