extract-repo 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/lib/extract_repo.rb +24 -34
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 111babbb2ba5b59cdf7dd53327df19a44c20929ed3154d66645562d7567343a1
4
- data.tar.gz: 78c79593377481d503d52064d276a077cdd207f15773c6e0741ded1f4516a1b2
3
+ metadata.gz: ff0ac721f57a6835cec23e2212bbda0c7e77e84159170ae987267045d4a771e9
4
+ data.tar.gz: e43e0030a41ff37fea7bb88375bc772a32bb50f6e661c1713c4c6da49bc6920c
5
5
  SHA512:
6
- metadata.gz: 85eeecc2d8df59d566402e2e63c5ec9500c864bca79459a13432b6961a2c23e379a46f6b3ba6cf1c0742f4c743613434355abefb322a841da8b4f148c08dc4bc
7
- data.tar.gz: 64e565bd2f1ac2495ff401f684e82bbde9a33257bd27da0878cd7919e93a9ee63ff3dba76dd73b00aebac9d4680f6e8a1b82899334cd1e58a166193faf77c912
6
+ metadata.gz: 4e578231b0f5dab20d385c385aefebc3c32037735766851f757be1587544ebbca5f1410499b5fa195755a139658e005f7ce9039f7f4a8efff7352aeaeaac688f
7
+ data.tar.gz: 612f90e4ebf638024437ec283b5a8bf1dab9f8f839b7983deec21e9a4700142f1b33b9b7f90fd44545c6876ddcbb16044d97e284ef0cc4813cc4fff3afb5591c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.8] - 2024-11-07
2
+
3
+ - Don't give the new repository the name of the source repository
4
+
5
+ ## [0.0.7] - 2024-10-18
6
+
7
+ - Fix URI bug
8
+
1
9
  ## [0.0.6] - 2024-10-06
2
10
 
3
11
  - Include boot files in gem
data/lib/extract_repo.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "pry"
2
+ require "uri"
2
3
  require "English"
4
+
3
5
  require "foobara/all"
4
6
 
5
7
  # TODO: allow extracting from a local repo and default to that repo as "."
@@ -41,26 +43,16 @@ class ExtractRepo < Foobara::Command
41
43
  Dir.chdir(File.expand_path(dir), &)
42
44
  end
43
45
 
44
- def repo_dir
45
- File.join(output_path, repo_name)
46
- end
47
-
48
- def repo_name
49
- File.basename(repo_url, ".git")
50
- end
51
-
52
46
  def mk_extract_dir
53
47
  sh "mkdir -p #{output_path}"
54
48
  end
55
49
 
56
50
  def rm_old_repo
57
- sh "rm -rf #{repo_dir}"
51
+ sh "rm -rf #{output_path}"
58
52
  end
59
53
 
60
54
  def clone_repo
61
- chdir output_path do
62
- sh "git clone #{absolute_repo_path}"
63
- end
55
+ sh "git clone #{absolute_repo_path} #{output_path}"
64
56
  end
65
57
 
66
58
  def local_repository?
@@ -68,19 +60,19 @@ class ExtractRepo < Foobara::Command
68
60
  end
69
61
 
70
62
  def remove_origin
71
- chdir repo_dir do
63
+ chdir output_path do
72
64
  sh "git remote rm origin"
73
65
  end
74
66
  end
75
67
 
76
68
  def remove_tags
77
- chdir repo_dir do
69
+ chdir output_path do
78
70
  sh "for i in `git tag`; do git tag -d $i; done"
79
71
  end
80
72
  end
81
73
 
82
74
  def remove_replaces
83
- chdir repo_dir do
75
+ chdir output_path do
84
76
  replace_sha1s = sh "git replace -l", silent: true
85
77
  replace_sha1s = replace_sha1s.chomp.split("\n")
86
78
  replace_sha1s.each do |replace_sha1|
@@ -93,27 +85,25 @@ class ExtractRepo < Foobara::Command
93
85
  end
94
86
 
95
87
  def determine_paths
96
- chdir repo_dir do
88
+ chdir output_path do
97
89
  self.file_paths = []
98
90
 
99
- chdir repo_dir do
100
- paths.each do |path|
101
- unless File.exist?(path)
102
- # :nocov:
103
- raise "Path #{path} does not exist in repo #{repo_dir}"
104
- # :nocov:
105
- end
91
+ paths.each do |path|
92
+ unless File.exist?(path)
93
+ # :nocov:
94
+ raise "Path #{path} does not exist in repo #{output_path}"
95
+ # :nocov:
96
+ end
106
97
 
107
- if File.directory?(path)
108
- Dir.glob("#{path}/**/*").each do |file|
109
- file_paths << file if File.file?(file)
110
- end
111
- else
112
- # TODO: test this path
113
- # :nocov:
114
- file_paths << path
115
- # :nocov:
98
+ if File.directory?(path)
99
+ Dir.glob("#{path}/**/*").each do |file|
100
+ file_paths << file if File.file?(file)
116
101
  end
102
+ else
103
+ # TODO: test this path
104
+ # :nocov:
105
+ file_paths << path
106
+ # :nocov:
117
107
  end
118
108
  end
119
109
  end
@@ -122,7 +112,7 @@ class ExtractRepo < Foobara::Command
122
112
  end
123
113
 
124
114
  def determine_historic_paths
125
- chdir repo_dir do
115
+ chdir output_path do
126
116
  file_paths.dup.each do |file_path|
127
117
  historic_paths = sh "git log --follow --name-only --pretty=format: -- \"#{file_path}\""
128
118
 
@@ -142,7 +132,7 @@ class ExtractRepo < Foobara::Command
142
132
  end
143
133
 
144
134
  def filter_repo
145
- chdir repo_dir do
135
+ chdir output_path do
146
136
  path_args = file_paths.map { |path| "--path #{path}" }.join(" ")
147
137
  sh "git-filter-repo #{path_args} --force --prune-degenerate always"
148
138
  end
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.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-07 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foobara
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
- rubygems_version: 3.5.21
83
+ rubygems_version: 3.5.23
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Extract code from one repository into a new repository, preserving history