Module: Bash::Merge

Defined in:
lib/bash/merge.rb,
lib/bash/merge/emitter.rb,
lib/bash/merge/version.rb,
lib/bash/merge/freeze_node.rb,
lib/bash/merge/debug_logger.rb,
lib/bash/merge/merge_result.rb,
lib/bash/merge/node_wrapper.rb,
lib/bash/merge/smart_merger.rb,
lib/bash/merge/file_analysis.rb,
lib/bash/merge/comment_tracker.rb,
sig/bash/merge.rbs

Overview

Smart merge system for Bash scripts using tree-sitter AST analysis. Provides intelligent merging by understanding Bash structure rather than treating files as plain text.

Defined Under Namespace

Modules: DebugLogger, Version Classes: Availability, CommentTracker, CorruptionDetectedError, DestinationParseError, Emitter, Error, FileAnalysis, FreezeNode, MergeResult, NodeWrapper, ParseError, SmartMerger, TemplateParseError

Constant Summary collapse

TREE_SITTER_BACKEND =
TreeHaver::KREUZBERG_LANGUAGE_PACK_BACKEND
BACKEND_REGISTRY =
Struct.new(:registered, :mutex).new(false, Mutex.new)
VERSION =

Current gem version exposed at the traditional constant location.

Returns:

  • (String)
Version::VERSION

Class Method Summary collapse

Class Method Details

.availability(source: "#!/usr/bin/env bash\necho hello\n") ⇒ Object



146
147
148
149
150
151
152
153
154
# File 'lib/bash/merge.rb', line 146

def availability(source: "#!/usr/bin/env bash\necho hello\n")
  diagnostics = []
  grammar_path = bash_grammar_path(diagnostics)
  Availability.new(
    grammar_path: grammar_path,
    node_parser: node_parser_available_for?(source, grammar_path, diagnostics),
    diagnostics: diagnostics
  )
end

.available?(source: "#!/usr/bin/env bash\necho hello\n") ⇒ Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/bash/merge.rb', line 142

def available?(source: "#!/usr/bin/env bash\necho hello\n")
  availability(source: source).available?
end

.available_bash_backendsObject



138
139
140
# File 'lib/bash/merge.rb', line 138

def available_bash_backends
  bash_backend_available_for_analysis?(TREE_SITTER_BACKEND.id) ? [TREE_SITTER_BACKEND] : []
end

.register_backend!Object



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/bash/merge.rb', line 125

def register_backend!
  BACKEND_REGISTRY.mutex.synchronize do
    return if BACKEND_REGISTRY.registered

    TreeHaver::BackendRegistry.register(TREE_SITTER_BACKEND)

    grammar_finder = TreeHaver::GrammarFinder.new(:bash)
    grammar_finder.register! if grammar_finder.available?

    BACKEND_REGISTRY.registered = true
  end
end