git_pr 0.0.3 → 0.0.4

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: b2f34b7e4efca226ef82cf93cb83384c37d494dc
4
- data.tar.gz: 7a8309aeced204c6d538248a912347e09abb5257
3
+ metadata.gz: b845e6d7a05d53f4bc31e91986cd886b56c88cd1
4
+ data.tar.gz: 157e6084f4c39dee37322508e0464cf371f07bc7
5
5
  SHA512:
6
- metadata.gz: 9d8676d8f76591b3cdb43bf82d9668ba1938d161ee80e0dbf077a4bb431da366be27e672b81c94bac7ade9388179d06c48a72cc14d8b6c808c6c5ff4cdbf4e79
7
- data.tar.gz: fc982079a187cd9427c2bbf87e574beb9d928047c74ca785cb00c02c700949451ddd3424c3baa4057b6732e0fbe48c955ae54f526bad8c1da80c54282ec74188
6
+ metadata.gz: 103b7d80a8719dde69faba086dd9b959d76c08458f083059c8c52ff7ccac99623eb540c9228c8d511f8ddce51f0a9613e38c3780b414882ec847024319343a65
7
+ data.tar.gz: f992d1c24326943f34d7568ede54c0fd094337c70ac11a88ccda9263bd230c8e6f1b5b90ed41562f9900a0e544e93190c032b6f9e2a118c8af868c184ea650cc
data/lib/git_pr/github.rb CHANGED
@@ -7,6 +7,7 @@ module GitPr
7
7
 
8
8
  AUTH_KEY_NAME = "git-merge-pull"
9
9
  NETRC_KEY = "#{AUTH_KEY_NAME}.api.github.com"
10
+ DEFAULT_REMOTE_KEY = "pr.defaultremote"
10
11
 
11
12
  def self.test_credentials
12
13
  n = Netrc.read
@@ -81,12 +82,17 @@ module GitPr
81
82
  def self.determine_project_name_from_command_line git, project_name, default_remotes
82
83
  # Figure out what GitHub project we're dealing with. First, did they pass us a name of
83
84
  # an existing remote, or did they pass a GitHub project?
84
- default_remote_from_gitconfig = git.config "pr.defaultremote"
85
+ default_remote_from_gitconfig = git.config DEFAULT_REMOTE_KEY
85
86
  if project_name
86
87
  project_remote = git.remotes.find { |x| x.name == project_name }
87
- elsif default_remote_from_gitconfig
88
- puts "Using pr.defaultremote setting '#{default_remote_from_gitconfig}' from gitconfig" if $verbose
88
+ elsif !default_remote_from_gitconfig.empty?
89
+ puts "Using #{DEFAULT_REMOTE_KEY} setting '#{default_remote_from_gitconfig}' from gitconfig" if $verbose
89
90
  project_remote = git.remotes.find { |x| x.name == default_remote_from_gitconfig }
91
+ unless project_remote
92
+ puts "The remote '#{default_remote_from_gitconfig}' doesn't exist.".red
93
+ puts "Fix the value of '#{DEFAULT_REMOTE_KEY}' in gitconfig.".red
94
+ exit -1
95
+ end
90
96
  else
91
97
  project_remote = git.remotes.find { |x| default_remotes.include? x.name }
92
98
  end
@@ -101,10 +107,16 @@ module GitPr
101
107
  github_project = project_name
102
108
  end
103
109
 
110
+ unless github_project
111
+ puts "Unable to determine the active GitHub project.".red
112
+ puts "For more help, run: git pr -h"
113
+ exit -1
114
+ end
115
+
104
116
  begin
105
117
  github_repo = Octokit.repo "#{github_project}"
106
118
  rescue
107
- puts "Project `#{github_project}` is not a valid GitHub project.".red
119
+ puts "Project '#{github_project}' is not a valid GitHub project.".red
108
120
  exit -1
109
121
  end
110
122
 
@@ -1,3 +1,3 @@
1
1
  module GitPr
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Sharon