gem-clone 0.4.2 → 0.4.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 +4 -4
- data/README.md +10 -2
- data/lib/rubygems/commands/clone_command.rb +21 -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: f05d7ae51f03ff10466a4db393f7ef54a12bede9bed12c7e1b45a94932334c7a
|
|
4
|
+
data.tar.gz: e88a27ac3b234f8a2111af37ac45797a1f4f1dae4b028fe75a7f45b775ef974b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24e912fb1c57eaa8f4c8eeacfddd464da3b59357fd87b613f976e5162ad3990d5dfa3ddcd87027a3614689a290fb58be1a798442f43b542960c9c42e74edeeca
|
|
7
|
+
data.tar.gz: e1f237bf55e5db12a6aa84559dd6431836fa48e7c34bc55f5346c036027a0e34c71c049ca13f488165d7fb71f036aef20e0574bc3659e847b582a43a6afbe927
|
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,10 @@ require 'uri'
|
|
|
5
5
|
require 'open3'
|
|
6
6
|
|
|
7
7
|
class Gem::Commands::CloneCommand < Gem::Command
|
|
8
|
+
# git goget answers with these for a repository it deliberately left alone.
|
|
9
|
+
GOGET_UNREACHABLE = 3
|
|
10
|
+
GOGET_LOCAL_WORK = 4
|
|
11
|
+
|
|
8
12
|
def initialize
|
|
9
13
|
super 'clone', 'Clone a gem repository using git goget, ghq, or git'
|
|
10
14
|
|
|
@@ -102,9 +106,11 @@ Examples:
|
|
|
102
106
|
def normalize_repository_url(url)
|
|
103
107
|
return url if url.nil? || url.empty?
|
|
104
108
|
|
|
105
|
-
normalized_url = url.
|
|
109
|
+
normalized_url = url.sub(/[#?].*/m, '')
|
|
110
|
+
normalized_url = normalized_url.sub(%r{\Ahttp://}, 'https://').sub(%r{\Ahttps://www\.}, 'https://')
|
|
111
|
+
normalized_url = normalized_url.gsub(%r{/(tree|blob|commits|releases|issues|pull|tags|branches)/.*$}, '')
|
|
106
112
|
|
|
107
|
-
normalized_url.chomp('/')
|
|
113
|
+
normalized_url.chomp('/').sub(/\.git\z/, '')
|
|
108
114
|
end
|
|
109
115
|
|
|
110
116
|
def clone_repository(url)
|
|
@@ -133,13 +139,18 @@ Examples:
|
|
|
133
139
|
end
|
|
134
140
|
|
|
135
141
|
def clone_with_git_goget(url)
|
|
136
|
-
|
|
137
|
-
say "Executing: #{command}" if options[:verbose]
|
|
142
|
+
say "Executing: git goget #{url}" if options[:verbose]
|
|
138
143
|
|
|
139
|
-
system(
|
|
144
|
+
system("git", "goget", url)
|
|
140
145
|
|
|
141
|
-
|
|
146
|
+
case $?.exitstatus
|
|
147
|
+
when 0
|
|
142
148
|
say "Successfully cloned repository: #{url}"
|
|
149
|
+
when GOGET_UNREACHABLE
|
|
150
|
+
alert_error "Repository is unreachable: #{url}"
|
|
151
|
+
terminate_interaction 1
|
|
152
|
+
when GOGET_LOCAL_WORK
|
|
153
|
+
alert_warning "Left the existing checkout alone: #{url}"
|
|
143
154
|
else
|
|
144
155
|
alert_error "Failed to clone repository with git goget."
|
|
145
156
|
terminate_interaction 1
|
|
@@ -147,11 +158,10 @@ Examples:
|
|
|
147
158
|
end
|
|
148
159
|
|
|
149
160
|
def clone_with_ghq(url)
|
|
150
|
-
command = "ghq get #{url}"
|
|
151
161
|
say "git goget not found, falling back to ghq" if options[:verbose]
|
|
152
|
-
say "Executing: #{
|
|
162
|
+
say "Executing: ghq get #{url}" if options[:verbose]
|
|
153
163
|
|
|
154
|
-
system(
|
|
164
|
+
system("ghq", "get", url)
|
|
155
165
|
|
|
156
166
|
if $?.success?
|
|
157
167
|
say "Successfully cloned repository: #{url}"
|
|
@@ -162,11 +172,10 @@ Examples:
|
|
|
162
172
|
end
|
|
163
173
|
|
|
164
174
|
def clone_with_git(url)
|
|
165
|
-
command = "git clone #{url}"
|
|
166
175
|
say "ghq not found, falling back to git clone" if options[:verbose]
|
|
167
|
-
say "Executing: #{
|
|
176
|
+
say "Executing: git clone #{url}" if options[:verbose]
|
|
168
177
|
|
|
169
|
-
system(
|
|
178
|
+
system("git", "clone", url)
|
|
170
179
|
|
|
171
180
|
if $?.success?
|
|
172
181
|
say "Successfully cloned repository: #{url}"
|