giturl 1.3.4 → 1.3.5

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: e43435dd2f65994223cba6a0102f6115be87e134fda05f1a3f3f9a070615f67a
4
- data.tar.gz: 41ec81451225da88086dec1ecdd0cd497ea0af313b6697df7ea6304fe1b00925
3
+ metadata.gz: 45b7398651ba238c84ddbe522bbb7cbf0c752d0f4be05d50645ed7ec687073ee
4
+ data.tar.gz: 0f8f2c669194a8fd7861a8708a388539e6ee877dc812368f52f97dbb65769f32
5
5
  SHA512:
6
- metadata.gz: 820f72055d3b78a15959da42539745736a8da5e0d7107ddab76f3841fa232e3bb8b4175fde24e98f91fae1200aa1656653a5f53fabfbcd210b39bfe6dd3e2505
7
- data.tar.gz: cda6f2388376fd9e4d1174d236dfe10bc7671e38f44b537499a66793586bd71b24e73dfdb834c63b4ec312e25bc13f23ac7fd31f26f2e27248fadfd621477892
6
+ metadata.gz: 642f9f0dea0c5bcba4ca594e9840bf6ed444f21ed84bd5b614c88521fbedab8a84737db6ef4517beb84cfd147cc140beaf23b19be32a2383ada14e4c4c4f733f
7
+ data.tar.gz: d3c6312a37aa378a1a9f3cda929a43d08fe1ceb86d03977e79af0bff29bdcfe559a8aef40bcfd6c44509517ae70f5b7228333d97cf8282686abf9cc5b814ce31
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ name: rspec (ruby ${{ matrix.ruby }})
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ['3.2', '3.3', '3.4', '4.0']
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache: true
22
+ - name: Configure git identity for spec fixtures
23
+ run: |
24
+ git config --global user.email "ci@example.com"
25
+ git config --global user.name "CI"
26
+ - run: bundle exec rspec
27
+
28
+ rubocop:
29
+ name: rubocop
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: '4.0'
36
+ bundler-cache: true
37
+ - run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -7,12 +7,13 @@
7
7
  # General guide-line is
8
8
  # https://github.com/rubocop-hq/ruby-style-guide
9
9
 
10
- require:
10
+ plugins:
11
11
  - rubocop-performance
12
12
  - rubocop-rspec
13
13
 
14
14
  AllCops:
15
15
  TargetRubyVersion: 2.3
16
+ NewCops: enable
16
17
 
17
18
  Layout/EndAlignment:
18
19
  Enabled: true
@@ -36,7 +37,7 @@ Lint/StructNewOverride:
36
37
  Metrics/BlockLength:
37
38
  Enabled: true
38
39
  Max: 30
39
- ExcludedMethods: ['describe', 'context']
40
+ AllowedMethods: ['describe', 'context']
40
41
 
41
42
  Metrics/MethodLength:
42
43
  Enabled: true
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 4.0.6
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## [v1.3.4](https://github.com/shinyaohtani/giturl/tree/v1.3.4 (2024-02-24)
3
+ ## [v1.3.5](https://github.com/shinyaohtani/giturl/tree/v1.3.5) (2026-09-03)
4
+
5
+ [Full Changelog](https://github.com/shinyaohtani/giturl/compare/v1.3.4...v1.3.5)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Fix root-dir bug, make specs hermetic, add CI, update all deps to latest [\#33](https://github.com/shinyaohtani/giturl/pull/33) ([shinyaohtani](https://github.com/shinyaohtani))
10
+
11
+ ## [v1.3.4](https://github.com/shinyaohtani/giturl/tree/v1.3.4) (2024-02-24)
4
12
 
5
13
  [Full Changelog](https://github.com/shinyaohtani/giturl/compare/v1.3.3...v1.3.4)
6
14
 
data/Gemfile CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Specify your gem's dependencies in giturl.gemspec
5
+ # Specify your gem's runtime dependency in giturl.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.0'
9
-
10
- gem 'rspec', '~> 3.0'
11
-
12
- gem 'rubocop', '~> 1.21'
8
+ # Development dependencies live here rather than in the gemspec
9
+ # (see Gemspec/DevelopmentDependencies).
10
+ gem 'github_changelog_generator', '>= 1.18.0'
11
+ gem 'pry', '>= 0.16.0'
12
+ gem 'pry-byebug', '>= 3.12.0'
13
+ gem 'rake', '>= 13.4.2'
14
+ gem 'rspec', '>= 3.13.2'
15
+ gem 'rubocop', '>= 1.90.0'
16
+ gem 'rubocop-performance', '>= 1.27.0'
17
+ gem 'rubocop-rspec', '>= 3.10.2'
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  ## What is giturl?
5
5
 
6
- `giturl`: A simple navigation tool for GitHub pages from local git-cloned directories Working deep in a git-cloned project and need to view its GitHub page? `giturl` simplifies this for you. A single command unveils your repository's URL. Want more? It also opens your browser and goes straight to the page -- no extra steps needed. `giturl` streamlines your workflow, merging simplicity with sophistication.
6
+ `giturl`: A simple navigation tool for GitHub pages from local git-cloned directories. Working deep in a git-cloned project and need to view its GitHub page? `giturl` simplifies this for you. A single command unveils your repository's URL. Want more? It also opens your browser and goes straight to the page -- no extra steps needed. `giturl` streamlines your workflow, merging simplicity with sophistication.
7
7
 
8
8
  You can use `giturl` like:
9
9
 
data/giturl.gemspec CHANGED
@@ -29,15 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
- spec.add_runtime_dependency 'launchy', '>= 2.5.0'
33
-
34
- spec.add_development_dependency 'bundler', '~> 2.0'
35
- spec.add_development_dependency 'github_changelog_generator', '>= 1.15.0'
36
- spec.add_development_dependency 'pry', '>= 0.12.2'
37
- spec.add_development_dependency 'pry-byebug', '>= 3.9.0'
38
- spec.add_development_dependency 'rake', '>= 12.3.3'
39
- spec.add_development_dependency 'rspec', '>= 3.9.0'
40
- spec.add_development_dependency 'rubocop', '>= 0.80.1'
41
- spec.add_development_dependency 'rubocop-performance', '>= 1.5.2'
42
- spec.add_development_dependency 'rubocop-rspec', '>= 1.38.1'
32
+ spec.add_dependency 'launchy', '>= 3.1.1'
33
+
34
+ spec.metadata['rubygems_mfa_required'] = 'true'
43
35
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Giturl
4
- VERSION = '1.3.4'
4
+ VERSION = '1.3.5'
5
5
  DESCRIPTION = <<~DESC
6
6
  giturl: A simple navigation tool for GitHub pages from local git-cloned directories.
7
7
 
data/lib/giturl.rb CHANGED
@@ -24,7 +24,7 @@ module Giturl
24
24
  # @return [Boolean] git-managed directory or not.
25
25
  def self.git_managed?(path)
26
26
  stderr_old = $stderr.dup
27
- $stderr.reopen('/dev/null')
27
+ $stderr.reopen(File::NULL)
28
28
  inside = `git -C #{path} rev-parse --is-inside-work-tree`.chomp
29
29
  $stderr.flush
30
30
  $stderr.reopen stderr_old
@@ -36,16 +36,53 @@ module Giturl
36
36
  # @param path [String] path for a git-managed directory. Both relative and absolute forms are accepted.
37
37
  # @return [String] GitHub web page URL for the given git-managed directory
38
38
  def self.convert(path)
39
- gitdir_prefix = `git -C #{path} rev-parse --show-prefix`.chomp
40
- gitdir_branch = `git -C #{path} rev-parse --abbrev-ref HEAD`.chomp
41
- remote_origin_url = `git -C #{path} config --get remote.origin.url`.chomp
42
-
43
- # remote_origin_url: git@github.com:shinyaohtani/giturl.git
44
- baseurl = remote_origin_url.tr(':', '/').gsub(/^.*@/, 'https://').gsub(/\.git$/, '')
45
- # gitdir_branch: feature/#1_user_named_branch
39
+ gitdir_prefix, gitdir_branch, remote_origin_url, ok = git_location_info(path)
40
+ unless ok
41
+ warn 'Git commands failed. Please check if the directory is a git repository.'
42
+ return ''
43
+ end
44
+ baseurl = construct_base_url(remote_origin_url)
46
45
  encoded_branch = gitdir_branch.split('/').map { |e| ERB::Util.url_encode(e) }.join('/')
47
-
48
46
  "#{baseurl}/tree/#{encoded_branch}/#{gitdir_prefix}"
49
47
  end
48
+
49
+ # Run the git commands needed to build the URL, and report whether they succeeded.
50
+ #
51
+ # @param path [String] path for a git-managed directory
52
+ # @return [Array(String, String, String, Boolean)] prefix, branch, remote origin URL, and
53
+ # whether the info is usable. gitdir_prefix may legitimately be empty (path is the
54
+ # repository root), so only command success and non-empty branch/remote are required.
55
+ def self.git_location_info(path)
56
+ prefix, prefix_ok = run_git(path, 'rev-parse', '--show-prefix')
57
+ branch, branch_ok = run_git(path, 'rev-parse', '--abbrev-ref', 'HEAD')
58
+ remote, remote_ok = run_git(path, 'config', '--get', 'remote.origin.url')
59
+ ok = prefix_ok && branch_ok && remote_ok && !branch.empty? && !remote.empty?
60
+ [prefix, branch, remote, ok]
61
+ end
62
+ private_class_method :git_location_info
63
+
64
+ def self.run_git(path, *args)
65
+ output = `git -C #{path} #{args.join(' ')}`.chomp
66
+ [output, $?.success?] # rubocop:disable Style/SpecialGlobalVars
67
+ end
68
+ private_class_method :run_git
69
+
70
+ def self.construct_base_url(remote_origin_url)
71
+ baseurl = remote_origin_url
72
+ if remote_origin_url =~ /@(.*?):/
73
+ host_alias = ::Regexp.last_match(1)
74
+ real_hostname = get_real_hostname(host_alias)
75
+ baseurl = remote_origin_url.sub(host_alias, real_hostname) if real_hostname && real_hostname != host_alias
76
+ end
77
+ baseurl.tr(':', '/').gsub(/^.*@/, 'https://').gsub(/\.git$/, '')
78
+ end
79
+
80
+ def self.get_real_hostname(host_alias)
81
+ ssh_output = `ssh -G #{host_alias} 2>#{File::NULL}`
82
+ real_hostname_line = ssh_output.lines.find { |line| line =~ /^hostname / }
83
+ return nil unless real_hostname_line
84
+
85
+ real_hostname_line.split[1]
86
+ end
50
87
  end
51
88
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: giturl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinya Ohtani (shinyaohtani@github)
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-02-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: launchy
@@ -16,140 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 2.5.0
18
+ version: 3.1.1
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: 2.5.0
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.0'
41
- - !ruby/object:Gem::Dependency
42
- name: github_changelog_generator
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 1.15.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 1.15.0
55
- - !ruby/object:Gem::Dependency
56
- name: pry
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 0.12.2
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: 0.12.2
69
- - !ruby/object:Gem::Dependency
70
- name: pry-byebug
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 3.9.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 3.9.0
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 12.3.3
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 12.3.3
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: 3.9.0
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: 3.9.0
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: 0.80.1
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 0.80.1
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-performance
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 1.5.2
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 1.5.2
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: 1.38.1
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: 1.38.1
25
+ version: 3.1.1
153
26
  description: |
154
27
  giturl: A simple navigation tool for GitHub pages from local git-cloned directories.
155
28
 
@@ -165,9 +38,11 @@ executables:
165
38
  extensions: []
166
39
  extra_rdoc_files: []
167
40
  files:
41
+ - ".github/workflows/ci.yml"
168
42
  - ".gitignore"
169
43
  - ".rspec"
170
44
  - ".rubocop.yml"
45
+ - ".ruby-version"
171
46
  - CHANGELOG.md
172
47
  - CODE_OF_CONDUCT.md
173
48
  - Gemfile
@@ -189,7 +64,7 @@ metadata:
189
64
  homepage_uri: https://github.com/shinyaohtani/giturl/blob/master/README.md
190
65
  source_code_uri: https://github.com/shinyaohtani/giturl
191
66
  changelog_uri: https://github.com/shinyaohtani/giturl/blob/master/CHANGELOG.md
192
- post_install_message:
67
+ rubygems_mfa_required: 'true'
193
68
  rdoc_options: []
194
69
  require_paths:
195
70
  - lib
@@ -204,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
79
  - !ruby/object:Gem::Version
205
80
  version: '0'
206
81
  requirements: []
207
- rubygems_version: 3.5.6
208
- signing_key:
82
+ rubygems_version: 4.0.16
209
83
  specification_version: 4
210
84
  summary: Show or open GitHub URL for your local directory
211
85
  test_files: []