repofetch 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fcfbdc976dd0c5345c0b46b617491569f862dfca0b770f7e8ba7a140580a799
4
- data.tar.gz: 6367a3ec9d1604ca2f9ca3bcc1916a4550cc9c05044f580233f62a0583b57f9e
3
+ metadata.gz: 3ad5af8ce1827ff6413451767fc8040cc710a057ecfde81d2d5db8c33282a15d
4
+ data.tar.gz: 3b9658cdeaf490accc551548464ea534e49b86a15dde562b16eec7da0d2d9d05
5
5
  SHA512:
6
- metadata.gz: c1cf7e66ceaa403c241adb2423882fcbc66e123f52f29311525bef0b13a98f45db205dc696374042cc1917e025b294e9256690f251ca1557c94360cf8d1a616b
7
- data.tar.gz: fb091b4fc478ec7a9ea70b334cdf01b388602da811dda13c970d99d9aa03fa34a5fd68db0083a46401c1040da2c5012d31cf01a395d6b35b17741ad8cb470335
6
+ metadata.gz: 07a62248fa6ff9248b85b01fc7f8376ae6b17fd5b9f30fce25a7e1ad139892b4ee230e84e3eb43b1aa2d1b94c66ee0be8f330100b2949b3ba95edbe7bb7cb2b2
7
+ data.tar.gz: 814a0249c286baf5523a461c50acadd75c2f31149185e5c8f8886e2f48feddcc770445fac5f6441092663cd1dbdea6dd40c2a457526d2740774be67bdafdc709
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- repofetch (0.4.3)
4
+ repofetch (0.4.4)
5
5
  actionview (~> 7.0, >= 7.0.4)
6
6
  dotenv (~> 2.8)
7
7
  faraday-retry (~> 2.0)
@@ -41,7 +41,7 @@ GEM
41
41
  faraday-net_http (3.0.2)
42
42
  faraday-retry (2.0.0)
43
43
  faraday (~> 2.0)
44
- git (1.13.0)
44
+ git (1.13.1)
45
45
  addressable (~> 2.8)
46
46
  rchardet (~> 1.8)
47
47
  i18n (1.12.0)
@@ -52,7 +52,7 @@ GEM
52
52
  crass (~> 1.0.2)
53
53
  nokogiri (>= 1.5.9)
54
54
  minitest (5.17.0)
55
- nokogiri (1.13.10-x86_64-linux)
55
+ nokogiri (1.14.0-x86_64-linux)
56
56
  racc (~> 1.4)
57
57
  octokit (6.0.1)
58
58
  faraday (>= 1, < 3)
@@ -107,7 +107,7 @@ GEM
107
107
  parser (>= 3.1.1.0)
108
108
  rubocop-rake (0.6.0)
109
109
  rubocop (~> 1.0)
110
- rubocop-rspec (2.16.0)
110
+ rubocop-rspec (2.17.0)
111
111
  rubocop (~> 1.33)
112
112
  ruby-progressbar (1.11.0)
113
113
  ruby2_keywords (0.0.5)
data/RELEASE_NOTES CHANGED
@@ -1,30 +1,6 @@
1
- 0.4.3
2
-
3
- ## Added
4
-
5
- - Bitbucket Cloud plugin
6
- - Simple help message for the GitLab plugin (`repofetch --plugin Repofetch::Gitlab -- --help`)
7
- - `--path` option, which is an alias for `--repository`
8
- - SSH url stat to GitHub and GitLab plugins
9
-
10
- ## Changed
11
-
12
- - "URL" stat in GitHub and GitLab plugins to "HTTP(S)"
13
- - GitLab header to be styled
1
+ Bitbucket Cloud Bugfix
14
2
 
15
3
  ## Fixed
16
4
 
17
- - Confusing error on incorrect CLI args for the GitLab plugin
18
-
19
- ## Breaking for users
20
-
21
- ### Changed
22
-
23
- - The `--plugin` short option to `-P`
24
- - `-p` to be the short option for `--path`
25
-
26
- ## Breaking for 3rd-party plugins
27
-
28
- ### Changed
29
-
30
- - The exception that is caught when initializing a plugin from `ArgumentError` to `Repofetch::PluginUsageError`
5
+ - Bitbucket Cloud not getting automatically detected when running `repofetch` in a
6
+ Bitbucket Cloud repository
@@ -11,6 +11,8 @@ class Repofetch
11
11
  class BitbucketCloud < Repofetch::Plugin
12
12
  include ActionView::Helpers::NumberHelper
13
13
 
14
+ HTTP_REMOTE_REGEX = %r{https?://bitbucket\.org/(?<owner>[\w._-]+)/(?<repo>[\w._-]+)}.freeze
15
+ SSH_REMOTE_REGEX = %r{git@bitbucket\.org:(?<owner>[\w._-]+)/(?<repo>[\w._-]+)}.freeze
14
16
  ASCII = File.read(File.expand_path('bitbucketcloud/ASCII', __dir__))
15
17
 
16
18
  attr_reader :repo_identifier
@@ -45,12 +47,43 @@ class Repofetch
45
47
  ENV.fetch('BITBUCKET_TOKEN', nil)
46
48
  end
47
49
 
48
- def self.matches_repo?(*)
49
- false
50
+ # Detects that the repository is a Bitbucket repository.
51
+ def self.matches_repo?(git)
52
+ default_remote = Repofetch.default_remote(git)
53
+ matches_remote?(default_remote&.url)
50
54
  end
51
55
 
52
- def self.from_git(*)
53
- new
56
+ # Detects that the remote URL is for a Bitbucket Cloud repository.
57
+ def self.matches_remote?(remote)
58
+ HTTP_REMOTE_REGEX.match?(remote) || SSH_REMOTE_REGEX.match?(remote)
59
+ end
60
+
61
+ # Gets the owner and repository from a GitHub local repository.
62
+ def self.repo_identifiers(git)
63
+ default_remote = Repofetch.default_remote(git)
64
+ remote_identifiers(default_remote&.url)
65
+ end
66
+
67
+ # Gets the owner and repository from a GitHub remote URL.
68
+ #
69
+ # Returns nil if there is no match.
70
+ def self.remote_identifiers(remote)
71
+ match = HTTP_REMOTE_REGEX.match(remote)
72
+ match = SSH_REMOTE_REGEX.match(remote) if match.nil?
73
+ raise "Remote #{remote.inspect} doesn't look like a Bitbucket Cloud remote" if match.nil?
74
+
75
+ [match[:owner], match[:repo].delete_suffix('.git')]
76
+ end
77
+
78
+ # Creates an instance from a +Git::Base+ instance.
79
+ #
80
+ # @raise [Repofetch::PluginUsageError] if this plugin was selected *and* arguments were passed.
81
+ def self.from_git(git, args)
82
+ raise Repofetch::PluginUsageError, 'Explicitly activate this plugin to CLI arguments' unless args.empty?
83
+
84
+ owner, repository = repo_identifiers(git)
85
+
86
+ new("#{owner}/#{repository}")
54
87
  end
55
88
 
56
89
  def self.from_args(args)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repofetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spenser Black
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-12 00:00:00.000000000 Z
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview