gem-clone 0.4.2 → 0.4.3
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 +4 -4
- data/README.md +10 -2
- data/lib/rubygems/commands/clone_command.rb +18 -12
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 836f42b5a4924b0e9d94246ff6d12bb2f39faa30c51647d8443f75a4f1b98656
|
|
4
|
+
data.tar.gz: 22c882c0be0897264b54cbf865e9ba234cd7ec05d778ece19431c1158c6e8577
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e911bd7cf6c713b46e3e9ca34da2edd34c2af8e6988e308ace4b403d7526a7722abc009f1b8c655f06f0da76fa5522cafffa82bceeaa8a2995dc2e80f1b60500
|
|
7
|
+
data.tar.gz: fb3c3a11745f66da76dc3db82173d3b01c611e5905578a6f3feeddac926bf8faa4208ca0c39ab95e6f5d2e8a1846ddf8dfdc9b16c3f477e6cd260b8c17a1819b
|
data/README.md
CHANGED
|
@@ -126,7 +126,7 @@ The plugin performs the following steps:
|
|
|
126
126
|
|
|
127
127
|
### URL Normalization
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
Gem metadata names the same repository in many shapes, so the plugin folds them to one before cloning. Common Git hosting service paths are removed:
|
|
130
130
|
|
|
131
131
|
- `/tree/*` → removed (GitHub, GitLab branches/tags)
|
|
132
132
|
- `/blob/*` → removed (GitHub, GitLab file views)
|
|
@@ -137,8 +137,16 @@ The plugin automatically normalizes repository URLs by removing common Git hosti
|
|
|
137
137
|
- `/tags/*` → removed (tag pages)
|
|
138
138
|
- `/branches/*` → removed (branch pages)
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
So is anything else that does not name the repository itself:
|
|
141
|
+
|
|
142
|
+
- `#fragment` and `?query` → removed
|
|
143
|
+
- `http://` → `https://`
|
|
144
|
+
- `https://www.` → `https://`
|
|
145
|
+
- trailing `/` and `.git` → removed
|
|
146
|
+
|
|
147
|
+
**Examples:**
|
|
141
148
|
- `https://github.com/rails/rails/tree/v8.0.2` → `https://github.com/rails/rails`
|
|
149
|
+
- `http://www.github.com/rails/rails.git` → `https://github.com/rails/rails`
|
|
142
150
|
|
|
143
151
|
### Cross-platform Support
|
|
144
152
|
|
|
@@ -5,6 +5,9 @@ require 'uri'
|
|
|
5
5
|
require 'open3'
|
|
6
6
|
|
|
7
7
|
class Gem::Commands::CloneCommand < Gem::Command
|
|
8
|
+
# git goget answers with this when the repository cannot be reached at all.
|
|
9
|
+
GOGET_SKIPPED = 3
|
|
10
|
+
|
|
8
11
|
def initialize
|
|
9
12
|
super 'clone', 'Clone a gem repository using git goget, ghq, or git'
|
|
10
13
|
|
|
@@ -102,9 +105,11 @@ Examples:
|
|
|
102
105
|
def normalize_repository_url(url)
|
|
103
106
|
return url if url.nil? || url.empty?
|
|
104
107
|
|
|
105
|
-
normalized_url = url.
|
|
108
|
+
normalized_url = url.sub(/[#?].*/m, '')
|
|
109
|
+
normalized_url = normalized_url.sub(%r{\Ahttp://}, 'https://').sub(%r{\Ahttps://www\.}, 'https://')
|
|
110
|
+
normalized_url = normalized_url.gsub(%r{/(tree|blob|commits|releases|issues|pull|tags|branches)/.*$}, '')
|
|
106
111
|
|
|
107
|
-
normalized_url.chomp('/')
|
|
112
|
+
normalized_url.chomp('/').sub(/\.git\z/, '')
|
|
108
113
|
end
|
|
109
114
|
|
|
110
115
|
def clone_repository(url)
|
|
@@ -133,13 +138,16 @@ Examples:
|
|
|
133
138
|
end
|
|
134
139
|
|
|
135
140
|
def clone_with_git_goget(url)
|
|
136
|
-
|
|
137
|
-
say "Executing: #{command}" if options[:verbose]
|
|
141
|
+
say "Executing: git goget #{url}" if options[:verbose]
|
|
138
142
|
|
|
139
|
-
system(
|
|
143
|
+
system("git", "goget", url)
|
|
140
144
|
|
|
141
|
-
|
|
145
|
+
case $?.exitstatus
|
|
146
|
+
when 0
|
|
142
147
|
say "Successfully cloned repository: #{url}"
|
|
148
|
+
when GOGET_SKIPPED
|
|
149
|
+
alert_error "Repository is unreachable: #{url}"
|
|
150
|
+
terminate_interaction 1
|
|
143
151
|
else
|
|
144
152
|
alert_error "Failed to clone repository with git goget."
|
|
145
153
|
terminate_interaction 1
|
|
@@ -147,11 +155,10 @@ Examples:
|
|
|
147
155
|
end
|
|
148
156
|
|
|
149
157
|
def clone_with_ghq(url)
|
|
150
|
-
command = "ghq get #{url}"
|
|
151
158
|
say "git goget not found, falling back to ghq" if options[:verbose]
|
|
152
|
-
say "Executing: #{
|
|
159
|
+
say "Executing: ghq get #{url}" if options[:verbose]
|
|
153
160
|
|
|
154
|
-
system(
|
|
161
|
+
system("ghq", "get", url)
|
|
155
162
|
|
|
156
163
|
if $?.success?
|
|
157
164
|
say "Successfully cloned repository: #{url}"
|
|
@@ -162,11 +169,10 @@ Examples:
|
|
|
162
169
|
end
|
|
163
170
|
|
|
164
171
|
def clone_with_git(url)
|
|
165
|
-
command = "git clone #{url}"
|
|
166
172
|
say "ghq not found, falling back to git clone" if options[:verbose]
|
|
167
|
-
say "Executing: #{
|
|
173
|
+
say "Executing: git clone #{url}" if options[:verbose]
|
|
168
174
|
|
|
169
|
-
system(
|
|
175
|
+
system("git", "clone", url)
|
|
170
176
|
|
|
171
177
|
if $?.success?
|
|
172
178
|
say "Successfully cloned repository: #{url}"
|