git-pairing 0.3.1 → 0.3.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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDI5NGIxODQxZWYxMzYyZjI2NDYxNTVhNzRmMGZjODUzZWM1ZjI4Zg==
4
+ OWRkNGNmYWViYzI0MTNhOTFlZmQ1MzFmOWQ3OThhOGFmZjI4NGU4NA==
5
5
  data.tar.gz: !binary |-
6
- YTQ1MmU4NmM0YmY1Njg4MTE5OWQxZTFmYmEyMDU4YTk0ZTU3ODNmNw==
6
+ MGZhYjY4MDYzMjY2ODkyOGZiOWIzZWFlZTg5M2NkYjI2ZGIzOGE2OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- N2IwNGFmOGMwMzhjMDc4MDg1YjY3NjgwMmE4OGZiM2YzZWRhNTcyMzZlNjky
10
- Zjk2ODBlZjExNTAwNjY1NDdhMjk2NTY1YmZlNTEyNmU0ZmM4YWM4M2EyNDM4
11
- MjBhYzgxZGQzOTQ5Zjk1MDU4ODdiNzM2NTNhOWRiMTQyZTkxYmQ=
9
+ OTNjMDUzYzE5OWVmMzM2ZDU2ODAxZjcwNmNlZmNlZjU5NzJkNTM2ZjE2Mzk2
10
+ Yzc1ZTgyMTIwNmNhOWM0ZTNkZTljNTAzYjE3YmE0MTRmOWEyNjIyYzJlMThl
11
+ OTQ2MmQyN2ZhOGFiZDJjODRjZDQxNWJlMTI5YmM4OWRlYzk1OGY=
12
12
  data.tar.gz: !binary |-
13
- NDlmOTY0MGRiN2NiODljNzNmZTdhYjdjOGIwNGU4ZGMwZjE1NDc0MDhjNTBl
14
- YTU3OWZhNDcxZjZiZTg3ZDdhMGZhNTEyZjFkOGNjZTUwZDBmOTc4ODU5ZDIx
15
- N2JlNDMxZjVlMjU3YzA5MmFhYzY3NGYzZmU2ZDM5ZmI3ZDExNmM=
13
+ OGMxMzg2YzcwOTY0NzhjNDExYWM1MWM3ZDAyMTMzYThiNGU4NzY2NDZlZDZk
14
+ ZmI0NjE0N2IwM2QxYWEzYTI1OTMwZDZiOTY5NDhjZmJmZWY5ZTk4NjJmOWRl
15
+ Y2RmYWM2Yzk0YTkxNzg3OGIyYjY5ZDhkNTk2M2ZkY2VlNWMzNWY=
data/README.md CHANGED
@@ -66,12 +66,8 @@ do not suit your fancy.
66
66
 
67
67
  # Known Issues
68
68
 
69
- * Does not currently work on Windows... Ubuntu and Mac OS X seem fine
70
- * May not play entirely nicely with github since they use the commiter's
69
+ * May make githubs graphs and stats inaccurate since it relies on the commiter's
71
70
  name and email address to generate statistics and links
72
- * Will not play nice with [Chris Kampmeier's
73
- git-pair](https://github.com/chrisk/git-pair) gem since it uses similar
74
- git command syntax (namely `git pair`)
75
71
 
76
72
  # Building
77
73
 
data/bin/git-pair CHANGED
@@ -12,8 +12,7 @@ require 'pp'
12
12
  path_to_conf = File.join(File.expand_path(ENV['HOME']),'.pairs')
13
13
  pairs_conf = GitPairs::Helper.init(path_to_conf)
14
14
 
15
- # Check if we are in a git repo
16
- Trollop::die "Not in a git repo" unless system 'git status > /dev/null 2>/dev/null'
15
+ GitPairs::Helper.git_repo?
17
16
 
18
17
  opts = Trollop::options do
19
18
  banner <<-EOS
data/bin/git-solo CHANGED
@@ -22,14 +22,11 @@ end
22
22
  initials = ARGV
23
23
  pairs_conf = GitPairs::Helper.init(File.join(File.expand_path(ENV['HOME']),'.pairs'))
24
24
 
25
- Trollop::die "Not in a git repo" unless system 'git status > /dev/null 2>/dev/null'
25
+ GitPairs::Helper.git_repo?
26
26
 
27
27
  if initials.nil? || initials.empty?
28
28
  # revert to global git config
29
- `git config --unset-all user.name > /dev/null 2>/dev/null`
30
- `git config --unset-all user.email > /dev/null 2>/dev/null`
31
- `git config --unset-all user.initials > /dev/null 2>/dev/null`
32
- `git config --remove-section user > /dev/null 2>/dev/null`
29
+ GitPairs::Helper.git_reset
33
30
  elsif GitPairs::Helper.exists?(pairs_conf, initials[0])
34
31
  # set local git config to single configured partner
35
32
  author = GitPairs::Helper.fetch(pairs_conf, initials[0])
data/bin/git-whoami CHANGED
@@ -14,5 +14,5 @@ Usage:
14
14
  EOS
15
15
  end
16
16
 
17
- Trollop::die "Please ensure that git is installed before using 'git whoami'" unless system 'git --version > /dev/null 2>/dev/null'
17
+ GitPairs::Helper.git_installed?
18
18
  GitPairs::Helper.whoami
data/lib/helper.rb CHANGED
@@ -5,11 +5,49 @@ require 'highline/import'
5
5
  module GitPairs
6
6
  class Helper
7
7
  # Functions for manipulating the .pairs config file
8
+ def self.windows?
9
+ windows = (RUBY_PLATFORM.to_s =~ /win32|mswin|mingw|cygwin/ || RUBY_PLATFORM.to_s == 'ruby') ? true : false
10
+ return windows
11
+ end
12
+
13
+ def self.git_installed?
14
+ warning = "Please ensure that git is installed before proceeding"
15
+ # Check if we are in a git repo
16
+ if self.windows?
17
+ Trollop::die warning unless system 'git --version > NUL 2>NUL'
18
+ else
19
+ Trollop::die warning unless system 'git --version > /dev/null 2>/dev/null'
20
+ end
21
+ end
22
+
23
+ def self.git_repo?
24
+ warning = "Not in a git repo"
25
+ # Check if we are in a git repo
26
+ if self.windows?
27
+ Trollop::die warning unless system 'git status > NUL 2>NUL'
28
+ else
29
+ Trollop::die warning unless system 'git status > /dev/null 2>/dev/null'
30
+ end
31
+ end
32
+
33
+ def self.git_reset
34
+ if self.windows?
35
+ `git config --unset-all user.name > NUL 2>NUL`
36
+ `git config --unset-all user.email > NUL 2>NUL`
37
+ `git config --unset-all user.initials > NUL 2>NUL`
38
+ `git config --remove-section user > NUL 2>NUL`
39
+ else
40
+ `git config --unset-all user.name > /dev/null 2>/dev/null`
41
+ `git config --unset-all user.email > /dev/null 2>/dev/null`
42
+ `git config --unset-all user.initials > /dev/null 2>/dev/null`
43
+ `git config --remove-section user > /dev/null 2>/dev/null`
44
+ end
45
+ end
8
46
 
9
47
  def self.init(path_to_conf)
10
48
  # Create config if it doesn't already exist
11
49
  unless File.exists?(path_to_conf)
12
- Trollop::die "Please ensure that git is installed before proceeding" unless system 'git --version > /dev/null 2>/dev/null'
50
+ self.git_installed?
13
51
  puts Paint["initializing git-pairing for the first time...", :yellow]
14
52
  name = `git config --global --get user.name`
15
53
  initials = ""
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-pairing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Quince