git_helper 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
  SHA256:
3
- metadata.gz: b9c80aa14abd85f6ebcff1a7c6592e71e4222273c8239c14c45ef905c4a3e549
4
- data.tar.gz: 973f3831d8587d46d5e37c7738b50b5f8bab12bab9b2ec3d8ef34379b61917ea
3
+ metadata.gz: be948f58bc902f2e3036bfc3379279afcc74012af9cb56ee1b1f8586ba9c0fa2
4
+ data.tar.gz: c4f8655fcaef1db1fba03ebb731932da6d185bb89c46ebc366781309b76ebd1d
5
5
  SHA512:
6
- metadata.gz: 4515350964ec6a6e998a912d5b53cc49c8f90bd6d9cf9acfa5a3d499ffbad71638068266716971924efd76d6692a7aa1a1523cbcefc5c20eaeaf8e99805689aa
7
- data.tar.gz: bfee7c84bc7d5a9a54172779bccbdbb56e0ad22f3776f8dc2d00228149ffcdf5de4dc5f3b5182aa92c6add8eec30cb0a70b7f8184fb5e1a8c8a2da2bf621007b
6
+ metadata.gz: d19cf35a128b640a265aa89f229022fd7be3629e6e8ae5f6f08504494b1ccc5231af4ff1e39fbd3014ddb78e8757dd1a9413110872bdd7c8da8ae86525e7776a
7
+ data.tar.gz: d50eb1904c56c2269c139f7275321eef5516c70de6973fb2b11f8ea0f6681f5db5389f3f629c8b16718a7390442031e4999d8620a3814647b64dae340c01b8d1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_helper (3.3.0)
4
+ git_helper (3.3.1)
5
5
  gitlab (~> 4.16)
6
6
  gli (~> 2.13)
7
7
  highline (~> 2.0)
@@ -4,10 +4,18 @@ module GitHelper
4
4
  config_file[:gitlab_token]
5
5
  end
6
6
 
7
+ def gitlab_user
8
+ config_file[:gitlab_user]
9
+ end
10
+
7
11
  def github_token
8
12
  config_file[:github_token]
9
13
  end
10
14
 
15
+ def github_user
16
+ config_file[:github_user]
17
+ end
18
+
11
19
  def git_config_file_path
12
20
  Dir.pwd.scan(/\A\/[\w]*\/[\w]*\//).first << git_config_file
13
21
  end
@@ -10,7 +10,10 @@ module GitHelper
10
10
 
11
11
  create_or_update_config_file if answer
12
12
 
13
- answer = highline.ask_yes_no("Do you wish to set up the Git Helper plugins? (y/n)")
13
+ answer = highline.ask_yes_no(
14
+ "Do you wish to set up the Git Helper plugins? (y/n) (This process will " \
15
+ "attempt to use your GitHub personal access token to authenticate)"
16
+ )
14
17
 
15
18
  if answer
16
19
  create_or_update_plugin_files
@@ -61,27 +64,33 @@ module GitHelper
61
64
  end
62
65
  end
63
66
 
64
- private def highline
65
- @highline ||= GitHelper::HighlineCli.new
66
- end
67
-
68
- private def config_file
69
- GitHelper::GitConfigReader.new.git_config_file_path
70
- end
71
-
72
67
  private def create_or_update_plugin_files
73
68
  plugins_dir = "#{Dir.pwd.scan(/\A\/[\w]*\/[\w]*\//).first}/.git_helper/plugins"
74
69
  plugins_url = 'https://api.github.com/repos/emmahsax/git_helper/contents/plugins'
75
70
  header = 'Accept: application/vnd.github.v3.raw'
71
+ token = git_config_reader.github_token
72
+ user = git_config_reader.github_user
76
73
 
77
74
  Dir.mkdir(plugins_dir) unless File.exists?(plugins_dir)
78
75
 
79
- all_plugins = JSON.parse(`curl -s -H "#{header}" -L "#{plugins_url}"`)
76
+ all_plugins = JSON.parse(`curl -s -u #{user}:#{token} -H "#{header}" -L "#{plugins_url}"`)
80
77
 
81
78
  all_plugins.each do |plugin|
82
- plugin_content = `curl -s -H "#{header}" -L "#{plugins_url}/#{plugin['name']}"`
79
+ plugin_content = `curl -s -u #{user}:#{token} -H "#{header}" -L "#{plugins_url}/#{plugin['name']}"`
83
80
  File.open("#{plugins_dir}/#{plugin['name']}", 'w') { |file| file.puts plugin_content }
84
81
  end
85
82
  end
83
+
84
+ private def config_file
85
+ git_config_reader.git_config_file_path
86
+ end
87
+
88
+ private def git_config_reader
89
+ @git_config_reader ||= GitHelper::GitConfigReader.new
90
+ end
91
+
92
+ private def highline
93
+ @highline ||= GitHelper::HighlineCli.new
94
+ end
86
95
  end
87
96
  end
@@ -1,3 +1,3 @@
1
1
  module GitHelper
2
- VERSION = '3.3.0'
2
+ VERSION = '3.3.1'
3
3
  end
@@ -2,14 +2,16 @@ require 'spec_helper'
2
2
  require 'git_helper'
3
3
 
4
4
  describe GitHelper::GitConfigReader do
5
+ let(:github_user) { Faker::Internet.username }
5
6
  let(:github_token) { Faker::Internet.password(max_length: 10) }
7
+ let(:gitlab_user) { Faker::Internet.username }
6
8
  let(:gitlab_token) { Faker::Internet.password(max_length: 10) }
7
9
 
8
10
  let(:config_file) {
9
11
  {
10
- github_user: Faker::Internet.username,
12
+ github_user: github_user,
11
13
  github_token: github_token,
12
- gitlab_user: Faker::Internet.username,
14
+ gitlab_user: gitlab_user,
13
15
  gitlab_token: gitlab_token
14
16
  }
15
17
  }
@@ -40,6 +42,30 @@ describe GitHelper::GitConfigReader do
40
42
  end
41
43
  end
42
44
 
45
+ describe '#github_user' do
46
+ it 'should locate the github_user' do
47
+ expect(subject).to receive(:config_file).and_return(config_file)
48
+ expect(subject.github_user).to eq(github_user)
49
+ end
50
+
51
+ it 'should call the config file' do
52
+ expect(subject).to receive(:config_file).and_return(config_file)
53
+ subject.github_user
54
+ end
55
+ end
56
+
57
+ describe '#gitlab_user' do
58
+ it 'should locate the gitlab_user' do
59
+ expect(subject).to receive(:config_file).and_return(config_file)
60
+ expect(subject.gitlab_user).to eq(gitlab_user)
61
+ end
62
+
63
+ it 'should call the config file' do
64
+ expect(subject).to receive(:config_file).and_return(config_file)
65
+ subject.gitlab_user
66
+ end
67
+ end
68
+
43
69
  describe '#config_file' do
44
70
  it 'should yaml load the file path' do
45
71
  expect(YAML).to receive(:load_file)
@@ -133,6 +133,11 @@ describe GitHelper::Setup do
133
133
  ]"
134
134
  end
135
135
 
136
+ before do
137
+ allow_any_instance_of(GitHelper::GitConfigReader).to receive(:github_token).and_return(Faker::Internet.password)
138
+ allow_any_instance_of(GitHelper::GitConfigReader).to receive(:github_user).and_return(Faker::Internet.username)
139
+ end
140
+
136
141
  it 'should create the directory if it does not exist' do
137
142
  allow(File).to receive(:exists?).and_return(false)
138
143
  allow(File).to receive(:open).and_return(nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_helper
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
  - Emma Sax