extract-repo 0.0.10 → 0.0.12
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 +8 -0
- data/README.md +10 -3
- data/boot/start.rb +0 -5
- data/lib/extract_repo.rb +25 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f84b4fa63a5dddf61e6d52afe17a9c875a468fd2bd0b91019fffff133219c65
|
4
|
+
data.tar.gz: f49854352455955e76c522221d3e9c9577f2186a75ee5143b989fe87e406150c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 210a960c88fe44a7a597771ac27fbfd7ba7ea68a0d9b6ad9972e35b4a3ffc0055d99c88ff96e817f4c6aaa2d17530b9e6b9f0a2543c8d4008b5d2362061f9808
|
7
|
+
data.tar.gz: df7822a2442e563fb77cacf14514fd7d535daae879111b76df942960d40acd4e783ccef24fe787c8e972e93c4a1cac4d5fdaef19f918b0bac624e513cf80c072
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.0.12] - 2025-05-07
|
2
|
+
|
3
|
+
- Avoid loading pry/pry-byebug if not needed
|
4
|
+
|
5
|
+
## [0.0.11] - 2025-04-23
|
6
|
+
|
7
|
+
- Fix problem that was including irrelevant file renames in the final git history
|
8
|
+
|
1
9
|
## [0.0.10] - 2025-04-15
|
2
10
|
|
3
11
|
- Remove pry as a required dependency
|
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# extract-repo
|
2
|
+
|
3
|
+
Extracts files from one repository into a new repository, preserving complete git history of the extracted files.
|
4
|
+
|
5
|
+
## Usage
|
2
6
|
|
3
7
|
Pass the repo to extract code from and a list of directories/files to extract from that repo.
|
4
8
|
|
5
9
|
```
|
6
|
-
$ ./bin/extract-repo
|
10
|
+
$ ./bin/extract-repo some_file.rb some/directory/to/extract/
|
11
|
+
extract-repo --delete-extracted --repo-url-or-path git@github.com:org/repo.git --output-path new/repo/path --paths some/dir some/file.ext some/other/dir
|
7
12
|
```
|
8
13
|
|
9
|
-
Results will wind up in
|
14
|
+
Results will wind up in `~/tmp/extract/` if you don't specify an `--output-path`
|
15
|
+
|
16
|
+
`--delete-extracted` will delete any files in the source repo that you extracted to the new repo.
|
10
17
|
|
11
18
|
## License
|
12
19
|
|
data/boot/start.rb
CHANGED
data/lib/extract_repo.rb
CHANGED
@@ -116,10 +116,32 @@ class ExtractRepo < Foobara::Command
|
|
116
116
|
def determine_historic_paths
|
117
117
|
chdir output_path do
|
118
118
|
file_paths.dup.each do |file_path|
|
119
|
-
|
119
|
+
renames = {}
|
120
120
|
|
121
|
-
|
122
|
-
|
121
|
+
relevant_sha1s = sh "git log --follow --pretty=format:%H -- \"#{file_path}\""
|
122
|
+
relevant_sha1s = relevant_sha1s.strip.split("\n")
|
123
|
+
|
124
|
+
relevant_sha1s.each do |sha1|
|
125
|
+
status_lines = sh "git diff-tree -M --no-commit-id --name-status -r #{sha1}"
|
126
|
+
status_lines = status_lines.strip.split("\n")
|
127
|
+
|
128
|
+
status_lines.each do |status_line|
|
129
|
+
next unless status_line.start_with?("R")
|
130
|
+
|
131
|
+
similarity, from_path, to_path = status_line.split("\t")
|
132
|
+
similarity = similarity.match(/^R0*(\d+)$/)[1].to_i
|
133
|
+
|
134
|
+
if similarity >= 80
|
135
|
+
renames[to_path] = from_path
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
loop do
|
141
|
+
file_path = renames[file_path]
|
142
|
+
break unless file_path
|
143
|
+
|
144
|
+
file_paths << file_path
|
123
145
|
end
|
124
146
|
end
|
125
147
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: foobara
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.6.
|
80
|
+
rubygems_version: 3.6.2
|
81
81
|
specification_version: 4
|
82
82
|
summary: Extract code from one repository into a new repository, preserving history
|
83
83
|
of the extracted files.
|