githelp 0.1.0 → 0.1.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: 6224d4653f7848cf6b964cfecf7cb9cc2c812831
4
- data.tar.gz: 00b553cad0ca0c3e671b3f8179d7a690bf92a299
3
+ metadata.gz: e1b462f001e8cba0fede1763f9bc76caad5f505d
4
+ data.tar.gz: 4d4e917946e0b816336dbed35cce2d98d6519404
5
5
  SHA512:
6
- metadata.gz: 45534e1d22236e18abf1da8cd100ea46a359b60176443e2d7ba95445cbec40425a951563b05873f8b67fc23e416c1a7d231b01a0afb5430845dd5b3dd3fc0db8
7
- data.tar.gz: 7e82020186ac0e32232e02a3a92067e37e974186bdd02d4d47174e949b509e9ef636ffa142da854df50645c4f0453f746984b245eeb743f1a6ba453316d586e8
6
+ metadata.gz: 3c30ecf1924f95e8116c73741056425c3798f85b428b4e867dc4399dcfe88d4c44fef4c1b5473e9c23dc8653284b656b35d08e33f9b47613040030f530297401
7
+ data.tar.gz: 08d0e031d4b99b1d1f6fb7537920ebe3f1b94f7a2f9b1f5ee35acbc72e7b841343c3da2e4604650b962ac2b4a735f7abb28dd022a94e10c2244d3e8369f4fbae
data/exe/githelp CHANGED
@@ -15,6 +15,11 @@ require "githelp"
15
15
 
16
16
  include Githelp
17
17
 
18
+ unless git_check
19
+ STDERR.puts "Use 'githelp' in a Git repository."
20
+ exit
21
+ end
22
+
18
23
  progpath = $0
19
24
  if File.symlink?(progpath)
20
25
  progpath = File.readlink(progpath)
data/githelp.gemspec CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib", "data", "bin"]
20
+ # spec.executables = ["githelp", "githelp-changed"]
21
+ spec.require_paths = ["lib", "data"]
21
22
 
22
23
  spec.add_development_dependency "bundler", "~> 1.10"
23
24
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,21 +1,39 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Githelp
4
+ def git_branch
5
+ begin
6
+ `git branch`
7
+ rescue
8
+ nil
9
+ end
10
+ end
11
+
4
12
  def branches
5
- `git branch`.split(/\n/).map { |line|
6
- line.chomp!
7
- line.sub(/^../,'')
8
- }
13
+ b = git_branch
14
+ if b
15
+ b.split(/\n/).map { |line|
16
+ line.chomp!
17
+ line.sub(/^../,'')
18
+ }
19
+ else
20
+ [ '##BRANCH##' ]
21
+ end
9
22
  end
10
23
 
11
24
  def branch
12
- `git branch`.split(/\n/).map { |line|
13
- line.chomp!
14
- if line =~ /^\* (.*)$/ then
15
- return $1
16
- end
17
- }
18
- ''
25
+ b = git_branch
26
+ if b
27
+ b.split(/\n/).map { |line|
28
+ line.chomp!
29
+ if line =~ /^\* (.*)$/ then
30
+ return $1
31
+ end
32
+ }
33
+ ''
34
+ else
35
+ ''
36
+ end
19
37
  end
20
38
  end
21
39
 
@@ -1,19 +1,36 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Githelp
4
+ def git_log_wc(since,file)
5
+ begin
6
+ `git log --oneline --since='#{since}' #{file} | wc`
7
+ rescue
8
+ nil
9
+ end
10
+ end
11
+
4
12
  def changed(since)
5
13
  files(true).find_all { |file|
6
- `git log --oneline --since='#{since}' #{file} | wc` !~ / 0 /
14
+ wc = git_log_wc(since,file)
15
+ if wc
16
+ wc !~ / 0 /
17
+ else
18
+ false
19
+ end
7
20
  }
8
21
  end
9
22
 
10
23
  def unchanged(since)
11
24
  files(true).find_all { |file|
12
- `git log --oneline --since='#{since}' #{file} | wc` =~ / 0 /
25
+ wc = git_log_wc(since,file)
26
+ if wc
27
+ wc =~ / 0 /
28
+ else
29
+ false
30
+ end
13
31
  }
14
32
  end
15
33
  end
16
-
17
34
 
18
35
 
19
36
 
data/lib/githelp/files.rb CHANGED
@@ -7,7 +7,11 @@ def files(force=false, argv=ARGV)
7
7
  #
8
8
  # 引数の中にファイル名とマッチするものがあればファイルリストを取得
9
9
  #
10
- list = `git ls-files`.split(/\n/)
10
+ list = begin
11
+ `git ls-files`.split(/\n/)
12
+ rescue
13
+ []
14
+ end
11
15
  matched = false
12
16
  list.each { |file|
13
17
  args.each { |arg|
@@ -0,0 +1,15 @@
1
+ # coding: utf-8
2
+
3
+ module Githelp
4
+ def git_check
5
+ res = nil
6
+ begin
7
+ res = `git log`
8
+ rescue
9
+ end
10
+ res != ''
11
+ end
12
+ end
13
+
14
+
15
+
data/lib/githelp/tags.rb CHANGED
@@ -8,7 +8,11 @@ module Githelp
8
8
  #
9
9
  # 引数の中にタグ名とマッチするものがあればタグリストを取得
10
10
  #
11
- list = `git tag`.split(/\n/)
11
+ list = begin
12
+ `git tag`.split(/\n/)
13
+ rescue
14
+ []
15
+ end
12
16
  matched = false
13
17
  list.each { |tag|
14
18
  args.each { |arg|
@@ -1,3 +1,3 @@
1
1
  module Githelp
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/githelp.rb CHANGED
@@ -12,6 +12,7 @@ require "githelp/numbers"
12
12
  require "githelp/branches"
13
13
  require "githelp/changes"
14
14
  require "githelp/glossary"
15
+ require "githelp/git_check"
15
16
 
16
17
  module Githelp
17
18
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githelp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiyuki Masui
@@ -116,6 +116,7 @@ files:
116
116
  - lib/githelp/branches.rb
117
117
  - lib/githelp/changes.rb
118
118
  - lib/githelp/files.rb
119
+ - lib/githelp/git_check.rb
119
120
  - lib/githelp/glossary.rb
120
121
  - lib/githelp/numbers.rb
121
122
  - lib/githelp/params.rb
@@ -131,7 +132,6 @@ rdoc_options: []
131
132
  require_paths:
132
133
  - lib
133
134
  - data
134
- - bin
135
135
  required_ruby_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ">="