gitingest 0.4.0 → 0.6.0
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 +24 -0
- data/README.md +17 -2
- data/bin/gitingest +6 -1
- data/index.html +948 -279
- data/lib/gitingest/generator.rb +79 -2
- data/lib/gitingest/version.rb +1 -1
- metadata +2 -2
data/lib/gitingest/generator.rb
CHANGED
@@ -96,6 +96,7 @@ module Gitingest
|
|
96
96
|
# @option options [Logger] :logger Custom logger instance
|
97
97
|
# @option options [Integer] :threads Number of threads to use (default: auto-detected)
|
98
98
|
# @option options [Integer] :thread_timeout Seconds to wait for thread pool shutdown (default: 60)
|
99
|
+
# @option options [Boolean] :show_structure Show repository directory structure (default: false)
|
99
100
|
def initialize(options = {})
|
100
101
|
@options = options
|
101
102
|
@repo_files = []
|
@@ -109,6 +110,12 @@ module Gitingest
|
|
109
110
|
# Main execution method for command line
|
110
111
|
def run
|
111
112
|
fetch_repository_contents
|
113
|
+
|
114
|
+
if @options[:show_structure]
|
115
|
+
puts generate_directory_structure
|
116
|
+
return
|
117
|
+
end
|
118
|
+
|
112
119
|
generate_file
|
113
120
|
end
|
114
121
|
|
@@ -144,6 +151,21 @@ module Gitingest
|
|
144
151
|
result
|
145
152
|
end
|
146
153
|
|
154
|
+
# Generate a textual representation of the repository's directory structure
|
155
|
+
#
|
156
|
+
# @return [String] The directory structure as a formatted string
|
157
|
+
def generate_directory_structure
|
158
|
+
fetch_repository_contents if @repo_files.empty?
|
159
|
+
|
160
|
+
@logger.info "Generating directory structure for #{@options[:repository]}"
|
161
|
+
|
162
|
+
repo_name = @options[:repository].split("/").last
|
163
|
+
structure = DirectoryStructureBuilder.new(repo_name, @repo_files).build
|
164
|
+
|
165
|
+
@logger.info "\n"
|
166
|
+
structure
|
167
|
+
end
|
168
|
+
|
147
169
|
private
|
148
170
|
|
149
171
|
# Set up logging based on verbosity options
|
@@ -165,10 +187,11 @@ module Gitingest
|
|
165
187
|
raise ArgumentError, "Repository is required" unless @options[:repository]
|
166
188
|
|
167
189
|
@options[:output_file] ||= "#{@options[:repository].split("/").last}_prompt.txt"
|
168
|
-
@options[:branch] ||=
|
190
|
+
@options[:branch] ||= :default
|
169
191
|
@options[:exclude] ||= []
|
170
192
|
@options[:threads] ||= DEFAULT_THREAD_COUNT
|
171
193
|
@options[:thread_timeout] ||= DEFAULT_THREAD_TIMEOUT
|
194
|
+
@options[:show_structure] ||= false
|
172
195
|
@excluded_patterns = DEFAULT_EXCLUDES + @options[:exclude]
|
173
196
|
end
|
174
197
|
|
@@ -215,7 +238,8 @@ module Gitingest
|
|
215
238
|
# Validate repository and branch access
|
216
239
|
def validate_repository_access
|
217
240
|
begin
|
218
|
-
@client.repository(@options[:repository])
|
241
|
+
repo = @client.repository(@options[:repository])
|
242
|
+
@options[:branch] = repo.default_branch if @options[:branch] == :default
|
219
243
|
rescue Octokit::Unauthorized
|
220
244
|
raise "Authentication error: Invalid or expired GitHub token"
|
221
245
|
rescue Octokit::NotFound
|
@@ -441,4 +465,57 @@ module Gitingest
|
|
441
465
|
end
|
442
466
|
end
|
443
467
|
end
|
468
|
+
|
469
|
+
# Helper class to build directory structure visualization
|
470
|
+
class DirectoryStructureBuilder
|
471
|
+
def initialize(root_name, files)
|
472
|
+
@root_name = root_name
|
473
|
+
@files = files.map(&:path)
|
474
|
+
end
|
475
|
+
|
476
|
+
def build
|
477
|
+
tree = { @root_name => {} }
|
478
|
+
|
479
|
+
@files.sort.each do |path|
|
480
|
+
parts = path.split("/")
|
481
|
+
current = tree[@root_name]
|
482
|
+
|
483
|
+
parts.each do |part|
|
484
|
+
if part == parts.last
|
485
|
+
current[part] = nil
|
486
|
+
else
|
487
|
+
current[part] ||= {}
|
488
|
+
current = current[part]
|
489
|
+
end
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
493
|
+
output = ["Directory structure:"]
|
494
|
+
render_tree(tree, "", output)
|
495
|
+
output.join("\n")
|
496
|
+
end
|
497
|
+
|
498
|
+
private
|
499
|
+
|
500
|
+
def render_tree(tree, prefix, output)
|
501
|
+
return if tree.nil?
|
502
|
+
|
503
|
+
tree.keys.each_with_index do |key, index|
|
504
|
+
is_last = index == tree.keys.size - 1
|
505
|
+
current_prefix = prefix
|
506
|
+
|
507
|
+
if prefix.empty?
|
508
|
+
output << "└── #{key}/"
|
509
|
+
current_prefix = " "
|
510
|
+
else
|
511
|
+
connector = is_last ? "└── " : "├── "
|
512
|
+
item = tree[key].is_a?(Hash) ? "#{key}/" : key
|
513
|
+
output << "#{prefix}#{connector}#{item}"
|
514
|
+
current_prefix = prefix + (is_last ? " " : "│ ")
|
515
|
+
end
|
516
|
+
|
517
|
+
render_tree(tree[key], current_prefix, output) if tree[key].is_a?(Hash)
|
518
|
+
end
|
519
|
+
end
|
520
|
+
end
|
444
521
|
end
|
data/lib/gitingest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitingest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide Santangelo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|