extract-repo 0.0.2 → 0.0.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/CHANGELOG.md +5 -0
- data/bin/extract-repo +8 -3
- data/lib/extract_repo.rb +38 -3
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9fd3a3ce2f14da2877eb2121751d1ac1b4ee3fe99638076d68ede350d2d7916
|
4
|
+
data.tar.gz: da8ea55545f812e170b0e1d35b3473e4358224c3b0cd49dbca2d82aad2ee24b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979ad101bcdd4089c5907f5eb5274d73acaafd13e0c327d68531f44e4b2384d310e78f9f235fab8eb4cab1f6f1335a63c035f7c7cae10cc5eea619e0f82d5d40
|
7
|
+
data.tar.gz: 6851d37168a3028add2b25b08ec112e2fb92330a799894ed1fdb582eb8b49d251c2ae215af6a48e2ba846668c3c92c663ca9ca42aafcba498f9c3461ec8dcf0e
|
data/CHANGELOG.md
CHANGED
data/bin/extract-repo
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative "../
|
3
|
+
require_relative "../boot"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
require "foobara/sh_cli_connector"
|
6
|
+
|
7
|
+
command_connector = Foobara::CommandConnectors::ShCliConnector.new(single_command_mode: true)
|
8
|
+
|
9
|
+
command_connector.connect(ExtractRepo)
|
10
|
+
|
11
|
+
command_connector.run(ARGV)
|
data/lib/extract_repo.rb
CHANGED
@@ -2,16 +2,19 @@ require "pry"
|
|
2
2
|
require "English"
|
3
3
|
require "foobara/all"
|
4
4
|
|
5
|
+
# TODO: allow extracting from a local repo and default to that repo as "."
|
5
6
|
class ExtractRepo < Foobara::Command
|
6
7
|
inputs do
|
7
8
|
repo_url :string, :required
|
8
9
|
paths [:string], :required
|
9
|
-
output_path :string, default: "
|
10
|
+
output_path :string, default: "#{Dir.home}/tmp/extract"
|
11
|
+
delete_extracted :boolean, default: false
|
10
12
|
end
|
11
13
|
|
12
|
-
attr_accessor :file_paths
|
14
|
+
attr_accessor :file_paths, :absolute_repo_path
|
13
15
|
|
14
16
|
def execute
|
17
|
+
determine_absolute_repo_path
|
15
18
|
mk_extract_dir
|
16
19
|
rm_old_repo
|
17
20
|
|
@@ -22,6 +25,16 @@ class ExtractRepo < Foobara::Command
|
|
22
25
|
determine_historic_paths
|
23
26
|
filter_repo
|
24
27
|
remove_replaces
|
28
|
+
|
29
|
+
delete_extracted_paths if delete_extracted?
|
30
|
+
end
|
31
|
+
|
32
|
+
def determine_absolute_repo_path
|
33
|
+
self.absolute_repo_path = if local_repository?
|
34
|
+
File.absolute_path(repo_url)
|
35
|
+
else
|
36
|
+
repo_url
|
37
|
+
end
|
25
38
|
end
|
26
39
|
|
27
40
|
def chdir(dir, &)
|
@@ -46,10 +59,14 @@ class ExtractRepo < Foobara::Command
|
|
46
59
|
|
47
60
|
def clone_repo
|
48
61
|
chdir output_path do
|
49
|
-
sh "git clone #{
|
62
|
+
sh "git clone #{absolute_repo_path}"
|
50
63
|
end
|
51
64
|
end
|
52
65
|
|
66
|
+
def local_repository?
|
67
|
+
!URI.parse(repo_url).scheme
|
68
|
+
end
|
69
|
+
|
53
70
|
def remove_origin
|
54
71
|
chdir repo_dir do
|
55
72
|
sh "git remote rm origin"
|
@@ -67,7 +84,10 @@ class ExtractRepo < Foobara::Command
|
|
67
84
|
replace_sha1s = sh "git replace -l", silent: true
|
68
85
|
replace_sha1s = replace_sha1s.chomp.split("\n")
|
69
86
|
replace_sha1s.each do |replace_sha1|
|
87
|
+
# It seems like some versions of git do not create replace markers when doing this
|
88
|
+
# :nocov:
|
70
89
|
sh "git replace -d #{replace_sha1}"
|
90
|
+
# :nocov:
|
71
91
|
end
|
72
92
|
end
|
73
93
|
end
|
@@ -128,6 +148,21 @@ class ExtractRepo < Foobara::Command
|
|
128
148
|
end
|
129
149
|
end
|
130
150
|
|
151
|
+
# This feels dangerous however it is opt-in at least
|
152
|
+
def delete_extracted_paths
|
153
|
+
return unless local_repository?
|
154
|
+
|
155
|
+
Dir.chdir absolute_repo_path do
|
156
|
+
paths.each do |path|
|
157
|
+
FileUtils.rm_r path
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def delete_extracted?
|
163
|
+
delete_extracted
|
164
|
+
end
|
165
|
+
|
131
166
|
def sh(cmd, dry_run: false, silent: false)
|
132
167
|
unless silent
|
133
168
|
puts cmd
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extract-repo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foobara
|
@@ -24,7 +24,21 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: foobara-sh-cli-connector
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
28
42
|
email:
|
29
43
|
- azimux@gmail.com
|
30
44
|
executables:
|
@@ -48,7 +62,7 @@ metadata:
|
|
48
62
|
source_code_uri: https://github.com/foobara/extract-repo
|
49
63
|
changelog_uri: https://github.com/foobara/extract-repo/blob/main/CHANGELOG.md
|
50
64
|
rubygems_mfa_required: 'true'
|
51
|
-
post_install_message:
|
65
|
+
post_install_message:
|
52
66
|
rdoc_options: []
|
53
67
|
require_paths:
|
54
68
|
- lib
|
@@ -63,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
77
|
- !ruby/object:Gem::Version
|
64
78
|
version: '0'
|
65
79
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
67
|
-
signing_key:
|
80
|
+
rubygems_version: 3.5.18
|
81
|
+
signing_key:
|
68
82
|
specification_version: 4
|
69
83
|
summary: Extract code from one repository into a new repository, preserving history
|
70
84
|
of the extracted files.
|