extract-repo 0.0.11 → 0.0.13

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: 8d5ea6956dc3a02f797894c47d0eaea989ce46d0dcaa355c5e16ef0111719b88
4
- data.tar.gz: c03ba66bd8348e32dc8bdc1dc35fd2adb60e9914b87207af01481b2585a54adf
3
+ metadata.gz: bf525d3153a759cfa0582560060b37be8b551273a4fb125093a32d532f387d4b
4
+ data.tar.gz: b6e33042ed4152c1ca152dd2d74ebecd3e272c22cde971f2f2566f660b6783e7
5
5
  SHA512:
6
- metadata.gz: 68931f1e4f076a9f2f810b78725092f05b97748c5a602c4d07174350dcd3dc69090b2525f134c55426b50c8e284a1cc3ae28f0497746a0d9019718b80c98579b
7
- data.tar.gz: 554b2bc2b3cfa2de1568d7b581f630b9445431c30159bc8c6ccc6b6975fb624dcca937600f56455cdf79607d5740a07f527b06e34a2052d79783b97d6f9e8635
6
+ metadata.gz: 263f94e63ae97a463544f3f88423f3721a76f70a49de3ccf48bdd6e21a53f0e7f7ede96a742eeb3ca6d1bf4dceee5b89ea8139ff121cf087d83fad884b47b31d
7
+ data.tar.gz: e460e830b312a465f4857a2c0437a0080d32e23445c5a3dc337b6b3a05de609d4a5919319b4790ebd27438627bbb35ddf12971a7d9c76ac5f4fcf7c3dfd3eceb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.13] - 2025-05-08
2
+
3
+ - Prevent infinite loops when a file had been renamed and later named back to its original name
4
+
5
+ ## [0.0.12] - 2025-05-07
6
+
7
+ - Avoid loading pry/pry-byebug if not needed
8
+
1
9
  ## [0.0.11] - 2025-04-23
2
10
 
3
11
  - Fix problem that was including irrelevant file renames in the final git history
data/README.md CHANGED
@@ -1,12 +1,19 @@
1
- # Usage
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 git@github.com:org/repo.git some_file.rb some/directory/to/extract/
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 ~/tmp/extract/
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
@@ -6,8 +6,3 @@ if File.exist?("#{__dir__}/../Gemfile")
6
6
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
7
7
  require "bundler/setup"
8
8
  end
9
-
10
- if %w[development test].include?(ENV["FOOBARA_ENV"])
11
- require "pry"
12
- require "pry-byebug"
13
- end
data/lib/extract_repo.rb CHANGED
@@ -132,16 +132,14 @@ class ExtractRepo < Foobara::Command
132
132
  similarity = similarity.match(/^R0*(\d+)$/)[1].to_i
133
133
 
134
134
  if similarity >= 80
135
- renames[to_path] = from_path
135
+ renames[to_path] ||= []
136
+ renames[to_path] << from_path
136
137
  end
137
138
  end
138
139
  end
139
140
 
140
- loop do
141
- file_path = renames[file_path]
142
- break unless file_path
143
-
144
- file_paths << file_path
141
+ determine_historic_paths_for_file(file_path, renames).each do |path|
142
+ file_paths << path
145
143
  end
146
144
  end
147
145
  end
@@ -149,6 +147,20 @@ class ExtractRepo < Foobara::Command
149
147
  normalize_file_paths
150
148
  end
151
149
 
150
+ def determine_historic_paths_for_file(file_path, renames, seen = Set.new)
151
+ return [] if seen.include?(file_path)
152
+
153
+ seen << file_path
154
+
155
+ file_paths = renames[file_path]
156
+
157
+ return [] unless file_paths
158
+
159
+ file_paths + file_paths.map do |path|
160
+ determine_historic_paths_for_file(path, renames, seen)
161
+ end.flatten
162
+ end
163
+
152
164
  def normalize_file_paths
153
165
  file_paths.sort!
154
166
  file_paths.uniq!
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.11
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2025-05-09 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.8
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.