extract-repo 1.0.0 → 1.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/lib/extract_repo.rb +25 -9
  4. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 279cf409025efec16fd9702f281e213c19ee215e41340c78e7cc62b35aa8037e
4
- data.tar.gz: bd23103eaeff5ff2868be10536d7a9b39ff34638d400ec9e229c7e923812de0b
3
+ metadata.gz: 5a9293c9fcfc7ca1fa0e6c1b6ea98fc2f8a49b759cc10e6fdf51c88c50810a05
4
+ data.tar.gz: ce6a41d8871ae90bd0b11e2e9bb5db5d42cc4a5f1637269d90cf9b47484c318b
5
5
  SHA512:
6
- metadata.gz: 416ff6088a903de40c826759ddea2b2a9c832694b28337c98f68bd1c79eb6a1df7d2fa45abc3bc93ff94ee0d921040f5f28acda92365d67cfb4c92f4f033df77
7
- data.tar.gz: 365e8e721796a98af15384a837b929a70402235e5706d3cfc440546b68ec322e1ab47d8ecb29e9d51ae5fc80db7e8b578fcca5558f0dd5ecfb4afaed87c454ed
6
+ metadata.gz: ebbb6934f7ba07f305efc9b5f619ba8e9693aec319e4a0575decd010b4122433e4151ec50c64004b38f344ddff4dbe1cbfb8ed9dbd44c8e2a6d833d47691603c
7
+ data.tar.gz: 72cdc37b3597fc725e6590a1e753e4db709f4e7453b740e204bb2a2eeaca9978fb839e74e5b08e9c797d471fd1e36d9a4f0b7e97b831f6715ac69db2a353bf7f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.0.2] - 2026-11-06
2
+
3
+ - Create new repo on main branch even if source repo is on a feature branch
4
+
5
+ ## [1.0.1] - 2026-11-04
6
+
7
+ - Handle FileUtils not being loaded in Ruby 4
8
+ - Support appending file paths with "/" without breaking things
9
+
1
10
  ## [0.0.14] - 2025-07-31
2
11
 
3
12
  - Bump deps and use 1.x.x versions of foobara gems
data/lib/extract_repo.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "uri"
2
2
  require "English"
3
+ require "fileutils"
3
4
 
4
5
  require "foobara/all"
5
6
 
@@ -29,6 +30,7 @@ class ExtractRepo < Foobara::Command
29
30
  determine_historic_paths
30
31
  filter_repo
31
32
  remove_replaces
33
+ change_to_main_if_needed
32
34
 
33
35
  delete_extracted_paths if delete_extracted?
34
36
  end
@@ -79,33 +81,47 @@ class ExtractRepo < Foobara::Command
79
81
  replace_sha1s = replace_sha1s.chomp.split("\n")
80
82
  replace_sha1s.each do |replace_sha1|
81
83
  # It seems like some versions of git do not create replace markers when doing this
82
- # :nocov:
84
+ # simplecov:disable
83
85
  sh "git replace -d #{replace_sha1}"
84
- # :nocov:
86
+ # simplecov:enable
85
87
  end
86
88
  end
87
89
  end
88
90
 
91
+ def change_to_main_if_needed
92
+ unless current_branch == "main"
93
+ chdir output_path do
94
+ sh "git branch -m main"
95
+ end
96
+ end
97
+ end
98
+
99
+ def current_branch
100
+ chdir output_path do
101
+ sh "git branch --show-current"
102
+ end.strip
103
+ end
104
+
89
105
  def determine_paths
90
106
  chdir output_path do
91
107
  self.file_paths = []
92
108
 
93
109
  paths.each do |path|
94
110
  unless File.exist?(path)
95
- # :nocov:
111
+ # simplecov:disable
96
112
  raise "Path #{path} does not exist in repo #{output_path}"
97
- # :nocov:
113
+ # simplecov:enable
98
114
  end
99
115
 
100
116
  if File.directory?(path)
101
- Dir.glob("#{path}/**/*").each do |file|
117
+ Dir.glob(File.join(path, "/**/*")).each do |file|
102
118
  file_paths << file if File.file?(file)
103
119
  end
104
120
  else
105
121
  # TODO: test this path
106
- # :nocov:
122
+ # simplecov:disable
107
123
  file_paths << path
108
- # :nocov:
124
+ # simplecov:enable
109
125
  end
110
126
  end
111
127
  end
@@ -199,9 +215,9 @@ class ExtractRepo < Foobara::Command
199
215
  result = `#{cmd}`
200
216
 
201
217
  unless $CHILD_STATUS.success?
202
- # :nocov:
218
+ # simplecov:disable
203
219
  raise "Command #{cmd} failed with status #{$CHILD_STATUS.exitstatus}: #{result}"
204
- # :nocov:
220
+ # simplecov:enable
205
221
  end
206
222
 
207
223
  result
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extract-repo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -71,13 +71,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 3.4.0
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '4.1'
74
77
  required_rubygems_version: !ruby/object:Gem::Requirement
75
78
  requirements:
76
79
  - - ">="
77
80
  - !ruby/object:Gem::Version
78
81
  version: '0'
79
82
  requirements: []
80
- rubygems_version: 3.6.9
83
+ rubygems_version: 4.0.24
81
84
  specification_version: 4
82
85
  summary: Extract code from one repository into a new repository, preserving history
83
86
  of the extracted files.