Class: PodBuilder::Command::GenerateLFS
- Inherits:
-
Object
- Object
- PodBuilder::Command::GenerateLFS
- Defined in:
- lib/pod_builder/command/generate_lfs.rb
Class Method Summary collapse
- .call(options) ⇒ Object
- .filter_files_by_size(files, size_kb) ⇒ Object
- .write_attributes(path, gitattributes_includes, gitattributes_excludes) ⇒ Object
Class Method Details
.call(options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pod_builder/command/generate_lfs.rb', line 6 def self.call() Configuration.check_inited unless Configuration.lfs_update_gitattributes return false end gitattributes_excludes = ["*.h", "*.hh", "*.m", "*.mm", "*.i", "*.c", "*.cc", "*.cxx", "*.cpp", "*.def", "*.inc", "*.inl", "*.swift", "*.modulemap", "*.strings", "*.png", "*.jpg", "*.gif", "*.html", "*.htm", "*.js", "*.json", "*.xml", "*.txt", "*.md", "*.rb", "*.sh", "*.py", "*.plist", "*.resolved", ".*", "README*", "LICENSE*"] gitattributes_includes_frameworks = ["**/* filter=lfs diff=lfs merge=lfs !text"] write_attributes(PodBuilder::basepath("Rome"), gitattributes_includes_frameworks, gitattributes_excludes) write_attributes(PodBuilder::basepath("dSYM"), gitattributes_includes_frameworks, gitattributes_excludes) if Configuration.lfs_include_pods_folder gitattributes_includes_pods = ["**/*.frameworks/**/* filter=lfs diff=lfs merge=lfs !text"] write_attributes(PodBuilder::project_path("Pods"), gitattributes_includes_pods, gitattributes_excludes) end end |
.filter_files_by_size(files, size_kb) ⇒ Object
27 28 29 |
# File 'lib/pod_builder/command/generate_lfs.rb', line 27 def self.filter_files_by_size(files, size_kb) return files.select { |x| File.size(x) / 1024 > Configuration.lfs_min_file_size } end |
.write_attributes(path, gitattributes_includes, gitattributes_excludes) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pod_builder/command/generate_lfs.rb', line 31 def self.write_attributes(path, gitattributes_includes, gitattributes_excludes) stop_marker = "# pb<stop>" start_marker = "# pb<start> (lines up to `#{stop_marker}` are autogenerated, don't modify this section)" gitattributes_items = [start_marker] gitattributes_items += gitattributes_includes + gitattributes_excludes.map { |x| "#{x} !filter !merge !diff" } gitattributes_items += [stop_marker] gitattributes_path = File.join(gitattributes_path, ".gitattributes") if !File.exist?(gitattributes_path) FileUtils.touch(gitattributes_path) end gitattributes_content = File.read(gitattributes_path) podbuilder_start_line_found = false gitattributes_content.each_line do |line| stripped_line = line.strip if stripped_line.start_with?(stop_marker) podbuilder_start_line_found = false next elsif stripped_line.start_with?(start_marker) podbuilder_start_line_found = true end unless !podbuilder_start_line_found next end gitattributes_items.push(line.strip) end File.write(gitattributes_path, gitattributes_items.join("\n")) end |