repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal/exit_spec.rb | spec/units/commands/internal/exit_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand::Exit do
it_behaves_like "an internal command"
describe '#execute' do
it 'exits the program' do
command = described_class.new('exit', [])
expect { command.execute(double('env')) }.to raise_exc... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal/source_spec.rb | spec/units/commands/internal/source_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand::Source do
it_behaves_like "an internal command"
describe "#execute" do
context "with a valid file" do
it "calls the FileRunner and returns true" do
env = double('env')
allow(Gitsh::... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal/echo_spec.rb | spec/units/commands/internal/echo_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand::Echo do
it_behaves_like "an internal command"
describe '#execute' do
it 'prints all arguments to the environment joined with a space' do
env = double('env', puts: nil)
command = described_cla... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal/set_spec.rb | spec/units/commands/internal/set_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand::Set do
it_behaves_like "an internal command"
describe '#execute' do
it 'sets a variable on the environment' do
env = spy('env')
command = described_class.new('set', ['foo', 'bar'])
com... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal/chdir_spec.rb | spec/units/commands/internal/chdir_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand::Chdir do
it_behaves_like "an internal command"
describe '#execute' do
it 'returns true for correct directories' do
env = double('Environment', puts_error: true)
command = described_class.new(... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal/help_spec.rb | spec/units/commands/internal/help_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand::Help do
it_behaves_like "an internal command"
describe "#execute" do
context "with no arguments" do
it "prints out some stuff" do
env = spy('env', puts: nil)
command = described_cla... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/git_repository/status_spec.rb | spec/units/git_repository/status_spec.rb | require 'spec_helper'
require 'gitsh/git_repository/status'
describe Gitsh::GitRepository::Status do
describe '#initialized?' do
it 'returns true when git directory exists' do
repository_git_dir = File.expand_path('../../../../.git', __FILE__)
status = Gitsh::GitRepository::Status.new('', repository_... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/tokens_to_words_spec.rb | spec/units/tab_completion/tokens_to_words_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/tokens_to_words'
describe Gitsh::TabCompletion::TokensToWords do
describe '#call' do
it 'converts an array of tokens to an array of words' do
expect(call(
[:WORD, 'foo'], [:SPACE], [:WORD, 'bar'],
)).to eq ['foo', 'bar']
expect(call(
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/visualization_spec.rb | spec/units/tab_completion/visualization_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/visualization'
describe Gitsh::TabCompletion::Visualization do
describe '#to_dot' do
it 'produces a description of the state graph in dot format' do
start_state = state('start')
end_state = state('end')
add_text_transition(start_state, 'a', en... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/context_spec.rb | spec/units/tab_completion/context_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/context'
describe Gitsh::TabCompletion::Context do
describe '#prior_words' do
it 'produces the words in the input before the word being completed' do
context = described_class.new('stash drop my-')
expect(context.prior_words).to eq %w(stash drop)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/automaton_spec.rb | spec/units/tab_completion/automaton_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/text_matcher'
require 'gitsh/tab_completion/automaton'
describe Gitsh::TabCompletion::Automaton do
describe '#match' do
context 'for a deterministic automaton' do
it 'returns a set containing the end state' do
# --> (0) --- a ---> (1)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl_spec.rb | spec/units/tab_completion/dsl_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl'
describe Gitsh::TabCompletion::DSL do
describe '.load' do
it 'builds a graph of automaton states by reading the given file' do
path = write_temp_completions_file([
'stash (apply|drop|pop|show)',
].join("\n"))
start_state = Gitsh::... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/automaton_factory_spec.rb | spec/units/tab_completion/automaton_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/automaton_factory'
describe Gitsh::TabCompletion::AutomatonFactory do
describe '.build' do
it 'loads the tab completion DSL file' do
config_directory = '/tmp/etc/gitsh'
env = double(:env, config_directory: config_directory)
start_state = stub_... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/facade_spec.rb | spec/units/tab_completion/facade_spec.rb | require 'spec_helper'
require 'gitsh/error'
require 'gitsh/tab_completion/facade'
describe Gitsh::TabCompletion::Facade do
describe '#call' do
context 'given input not ending with a variable' do
it 'invokes the CommandCompleter' do
input = 'add -p $path lib/'
line_editor = double(:line_edit... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/alias_expander_spec.rb | spec/units/tab_completion/alias_expander_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/alias_expander'
describe Gitsh::TabCompletion::AliasExpander do
describe '#call' do
context 'when the first word is an alias for a Git command' do
it 'expands the alias' do
env = double(:env)
allow(env).to receive(:fetch).with('alias.alias... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/command_completer_spec.rb | spec/units/tab_completion/command_completer_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/command_completer'
describe Gitsh::TabCompletion::CommandCompleter do
describe '#call' do
it 'produces completions using an Automaton' do
automaton = build_automaton(completions: ['my-stash'])
completer = described_class.new(
build_line_edit... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/variable_completer_spec.rb | spec/units/tab_completion/variable_completer_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/variable_completer'
describe Gitsh::TabCompletion::VariableCompleter do
describe '#call' do
context 'with a variable not wrapped in braces' do
it 'produces variable completions that match the input' do
completer = described_class.new(
bu... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/escaper_spec.rb | spec/units/tab_completion/escaper_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/escaper'
describe Gitsh::TabCompletion::Escaper do
describe '#escape' do
context 'without any quote characters' do
it 'escapes spaces, slashes, quotes, operators, etc.' do
line_editor = double(:line_editor, completion_quote_character: nil)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/choice_factory_spec.rb | spec/units/tab_completion/dsl/choice_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/choice_factory'
describe Gitsh::TabCompletion::DSL::ChoiceFactory do
describe '#build' do
it 'applies all of the choice factories to the same end state' do
start_state = double(:start_state)
first_choice = double(:first_choice, build: nil)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/rule_set_factory_spec.rb | spec/units/tab_completion/dsl/rule_set_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/rule_set_factory'
require 'gitsh/tab_completion/dsl/rule_factory'
describe Gitsh::TabCompletion::DSL::RuleSetFactory do
describe '#build' do
it 'delegates to the various rule factories' do
start_state = double(:start_state)
rule_factory_1 = stub... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/plus_operation_factory_spec.rb | spec/units/tab_completion/dsl/plus_operation_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/plus_operation_factory'
describe Gitsh::TabCompletion::DSL::PlusOperationFactory do
describe '#build' do
it 'calls the child factory and adds a free transition' do
start_state = double(:start_state)
end_state = double(:end_state, add_free_transi... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/fallback_transition_factory_spec.rb | spec/units/tab_completion/dsl/fallback_transition_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/fallback_transition_factory'
describe Gitsh::TabCompletion::DSL::FallbackTransitionFactory do
describe '#build' do
it 'adds a fallback transition to the start state and returns the end state' do
start_state = double(:start_state, add_fallback_transiti... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/parse_error_spec.rb | spec/units/tab_completion/dsl/parse_error_spec.rb | require 'spec_helper'
require 'rltk'
require 'gitsh/tab_completion/dsl/parse_error'
describe Gitsh::TabCompletion::DSL::ParseError do
describe '#to_s' do
it 'describes the token where the problem occurred' do
position = instance_double(
RLTK::StreamPosition,
line_number: 2,
line_off... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/option_transition_factory_spec.rb | spec/units/tab_completion/dsl/option_transition_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/option_transition_factory'
describe Gitsh::TabCompletion::DSL::OptionTransitionFactory do
describe '#build' do
it 'adds transitions for known and unknown options' do
unknown_option_matcher = stub_unknown_option_matcher
start_state = double(:star... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/variable_transition_factory_spec.rb | spec/units/tab_completion/dsl/variable_transition_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/variable_transition_factory'
describe Gitsh::TabCompletion::DSL::VariableTransitionFactory do
describe '#build' do
it 'adds a transition to the start state and returns the end state' do
matcher = double(:matcher, name: 'my-matcher')
start_state ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/rule_factory_spec.rb | spec/units/tab_completion/dsl/rule_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/rule_factory'
describe Gitsh::TabCompletion::DSL::RuleFactory do
describe '#build' do
it "delegates to the rule's root factory" do
start_state = double(:start_state)
root = double(:factory, build: nil)
options = double(:options)
fact... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/text_transition_factory_spec.rb | spec/units/tab_completion/dsl/text_transition_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/text_transition_factory'
describe Gitsh::TabCompletion::DSL::TextTransitionFactory do
describe '#build' do
it 'adds a transition to the start state and returns the end state' do
start_state = double(:start_state, add_transition: nil)
matcher = s... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/star_operation_factory_spec.rb | spec/units/tab_completion/dsl/star_operation_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/star_operation_factory'
describe Gitsh::TabCompletion::DSL::StarOperationFactory do
describe '#build' do
it 'calls the child factory with the start state as the end state' do
start_state = double(:start_state)
child_result = double(:child_result... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/parser_spec.rb | spec/units/tab_completion/dsl/parser_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/parser'
describe Gitsh::TabCompletion::DSL::Parser do
describe '.parse' do
it 'parses single words' do
result = parse_single_rule(tokens([:WORD, 'stash'], [:EOS]))
expect(result).to be_a_text_transition
expect(result.word).to eq('stash')
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/concatenation_factory_spec.rb | spec/units/tab_completion/dsl/concatenation_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/concatenation_factory'
describe Gitsh::TabCompletion::DSL::ConcatenationFactory do
describe '#build' do
it 'connects the various parts in a sequence, and returns the end state' do
start_state = double(:start_state)
end_state_1 = double(:end_stat... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/lexer_spec.rb | spec/units/tab_completion/dsl/lexer_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/lexer'
describe Gitsh::TabCompletion::DSL::Lexer do
describe '.lex' do
it 'recognises space separated words' do
expect('stash pop').to produce_tokens ['WORD(stash)', 'WORD(pop)', 'EOS']
end
it 'recognises colon-prefixed words' do
expect... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/dsl/maybe_operation_factory_spec.rb | spec/units/tab_completion/dsl/maybe_operation_factory_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/maybe_operation_factory'
describe Gitsh::TabCompletion::DSL::MaybeOperationFactory do
describe '#build' do
it 'calls the child factory and adds a free transition' do
start_state = double(:start_state, add_free_transition: nil)
end_state = double... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/tag_matchers_spec.rb | spec/units/tab_completion/matchers/tag_matchers_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/tag_matcher'
describe Gitsh::TabCompletion::Matchers::TagMatcher do
describe '#match?' do
it 'always returns true' do
matcher = described_class.new(double(:env))
expect(matcher.match?('foo')).to be_truthy
expect(matcher.match?('')).t... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/unknown_option_matcher_spec.rb | spec/units/tab_completion/matchers/unknown_option_matcher_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/unknown_option_matcher'
describe Gitsh::TabCompletion::Matchers::UnknownOptionMatcher do
describe '#match?' do
it 'returns true for input starting with "-"' do
matcher = described_class.new
expect(matcher.match?('-a')).to be_truthy
e... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/command_matcher_spec.rb | spec/units/tab_completion/matchers/command_matcher_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/command_matcher'
describe Gitsh::TabCompletion::Matchers::CommandMatcher do
describe '#match?' do
it 'always returns true' do
matcher = described_class.new(double(:env), double(:internal_command))
expect(matcher.match?('foo')).to be_truthy... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/branch_matchers_spec.rb | spec/units/tab_completion/matchers/branch_matchers_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/branch_matcher'
describe Gitsh::TabCompletion::Matchers::BranchMatcher do
describe '#match?' do
it 'always returns true' do
matcher = described_class.new(double(:env))
expect(matcher.match?('foo')).to be_truthy
expect(matcher.match?(... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/anything_matcher_spec.rb | spec/units/tab_completion/matchers/anything_matcher_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/anything_matcher'
describe Gitsh::TabCompletion::Matchers::AnythingMatcher do
describe '#match?' do
it 'returns true for all input' do
matcher = described_class.new(double(:env))
expect(matcher.match?('foo')).to be_truthy
expect(matc... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/revision_matcher_spec.rb | spec/units/tab_completion/matchers/revision_matcher_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/revision_matcher'
describe Gitsh::TabCompletion::Matchers::RevisionMatcher do
describe '#match?' do
it 'always returns true' do
matcher = described_class.new(double(:env))
expect(matcher.match?('foo')).to be_truthy
expect(matcher.mat... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/path_matcher_spec.rb | spec/units/tab_completion/matchers/path_matcher_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/path_matcher'
describe Gitsh::TabCompletion::Matchers::PathMatcher do
describe '#match?' do
it 'always returns true' do
matcher = described_class.new(double(:env))
expect(matcher.match?('foo')).to be_truthy
expect(matcher.match?(''))... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/remote_matcher_spec.rb | spec/units/tab_completion/matchers/remote_matcher_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/remote_matcher'
describe Gitsh::TabCompletion::Matchers::RemoteMatcher do
describe '#match?' do
it 'always returns true' do
matcher = described_class.new(double(:env))
expect(matcher.match?('foo')).to be_truthy
expect(matcher.match?(... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/tab_completion/matchers/text_matcher_spec.rb | spec/units/tab_completion/matchers/text_matcher_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/matchers/text_matcher'
describe Gitsh::TabCompletion::Matchers::TextMatcher do
describe '#match?' do
it 'returns true when given the same word' do
expect(described_class.new('commit').match?('commit')).to be_truthy
end
it 'returns false when give... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/lexer/character_class_spec.rb | spec/units/lexer/character_class_spec.rb | require 'spec_helper'
require 'gitsh/lexer/character_class'
describe Gitsh::Lexer::CharacterClass do
describe '#characters' do
it 'returns the characters passed to the initializer' do
chars = ['a', 'e', 'i', 'o', 'u']
vowels = described_class.new(chars)
expect(vowels.characters).to eq chars
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/capturing_environment.rb | lib/gitsh/capturing_environment.rb | require 'delegate'
module Gitsh
class CapturingEnvironment < SimpleDelegator
def initialize(env)
super
@reader, @writer = IO.pipe
end
def output_stream
writer
end
def print(*args)
output_stream.print(*args)
end
def puts(*args)
output_stream.puts(*args)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/line_editor.rb | lib/gitsh/line_editor.rb | require 'gitsh/line_editor_native'
module Gitsh
module LineEditor
def self.delete_text(*args)
return if line_buffer.nil?
if args.length.zero?
beg = 0
len = line_buffer.length
elsif args.length == 1 && args[0].is_a?(Range)
beg = args[0].begin
len = line_buffer[ar... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/prompter.rb | lib/gitsh/prompter.rb | # encoding: utf-8
require 'gitsh/colors'
require 'gitsh/prompt_color'
module Gitsh
class Prompter
DEFAULT_FORMAT = "%D %c%B%#%w".freeze
BRANCH_CHAR_LIMIT = 15
def initialize(options={})
@env = options.fetch(:env)
@use_color = options.fetch(:color, true)
@prompt_color = options.fetch(:... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/environment.rb | lib/gitsh/environment.rb | require 'gitsh/error'
require 'gitsh/git_repository'
require 'gitsh/line_editor'
require 'gitsh/magic_variables'
module Gitsh
class Environment
DEFAULT_GIT_COMMAND = '/usr/bin/env git'.freeze
DEFAULT_CONFIG_DIRECTORY = '/usr/local/etc/gitsh'.freeze
attr_reader :input_stream, :output_stream, :error_strea... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/file_runner.rb | lib/gitsh/file_runner.rb | require 'gitsh/interpreter'
require 'gitsh/input_strategies/file'
module Gitsh
class FileRunner
def self.run(opts)
new(opts).run
end
def initialize(opts)
@env = opts.fetch(:env)
@path = opts.fetch(:path)
end
def run
interpreter.run
end
private
attr_reader :... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/quote_detector.rb | lib/gitsh/quote_detector.rb | module Gitsh
class QuoteDetector
def call(text, index)
index > 0 && text[index - 1] == '\\' && !call(text, index - 1)
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/shell_command_runner.rb | lib/gitsh/shell_command_runner.rb | module Gitsh
class ShellCommandRunner
def self.run(command_with_arguments, env)
new(command_with_arguments, env).run
end
def initialize(command_with_arguments, env)
@command_with_arguments = command_with_arguments
@env = env
end
def run
pid = Process.spawn(
*comma... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/parser.rb | lib/gitsh/parser.rb | require 'rltk'
require 'gitsh/arguments/string_argument'
require 'gitsh/arguments/composite_argument'
require 'gitsh/arguments/variable_argument'
require 'gitsh/arguments/subshell'
require 'gitsh/commands/lazy_command'
require 'gitsh/commands/noop'
require 'gitsh/commands/tree'
module Gitsh
class Parser < RLTK::Pars... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/exit_statuses.rb | lib/gitsh/exit_statuses.rb | module Gitsh
EX_OK = 0
EX_USAGE = 64
EX_NOINPUT = 66
EX_UNAVAILABLE = 69
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/argument_list.rb | lib/gitsh/argument_list.rb | module Gitsh
class ArgumentList
def initialize(args)
@args = args
end
def length
args.length
end
def values(env)
@args.map do |arg|
arg.value(env)
end
end
private
attr_reader :args
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/magic_variables.rb | lib/gitsh/magic_variables.rb | module Gitsh
class MagicVariables
def initialize(repo)
@repo = repo
end
def fetch(key)
if available_variables.include?(key)
send(key)
else
yield
end
end
def available_variables
private_methods(false).grep(/^_/)
end
private
attr_reader :... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/git_repository.rb | lib/gitsh/git_repository.rb | require 'open3'
require 'shellwords'
require 'gitsh/git_repository/status'
require 'gitsh/git_command_list'
module Gitsh
class GitRepository
def initialize(env, options={})
@env = env
@status_factory = options.fetch(:status_factory, Status)
end
def git_dir
git_output('rev-parse --git-d... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/module_delegator.rb | lib/gitsh/module_delegator.rb | class ModuleDelegator < Module
def initialize(module_delegator_target)
@module_delegator_target = module_delegator_target
end
def method_missing(method_name, *args, &block)
module_delegator_target.send(method_name, *args, &block)
end
def respond_to_missing?(method_name, include_all)
module_deleg... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/lexer.rb | lib/gitsh/lexer.rb | require 'rltk/lexer'
require 'gitsh/lexer/character_class'
module Gitsh
class Lexer < RLTK::Lexer
UNQUOTED_STRING_ESCAPABLES = CharacterClass.new([
' ', "\t", "\r", "\n", "\f", # Whitespace
"'", '"', # Quoted string delimiter
'&', '|', ';', # Command separato... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/prompt_color.rb | lib/gitsh/prompt_color.rb | require 'gitsh/colors'
module Gitsh
class PromptColor
def initialize(env)
@env = env
end
def status_color(status)
if !status.initialized?
env.repo_config_color('gitsh.color.uninitialized', 'normal red')
elsif status.has_untracked_files?
env.repo_config_color('gitsh.colo... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/line_editor_history_filter.rb | lib/gitsh/line_editor_history_filter.rb | require 'gitsh/module_delegator'
module Gitsh
class LineEditorHistoryFilter < ModuleDelegator
def readline(prompt, add_hist = false)
module_delegator_target.readline(prompt, add_hist).tap do |input|
if add_hist && input && should_not_have_been_added_to_history?
history.pop
end
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/terminal.rb | lib/gitsh/terminal.rb | require 'singleton'
require 'open3'
module Gitsh
class Terminal
include Singleton
class UnknownSizeError < StandardError; end
def color_support?
execute('tput colors').to_i > 0
end
def size
size_from_stty || size_from_tput
end
private
def size_from_stty
size = e... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/cli.rb | lib/gitsh/cli.rb | require 'optparse'
require 'gitsh/environment'
require 'gitsh/exit_statuses'
require 'gitsh/input_strategies/file'
require 'gitsh/input_strategies/interactive'
require 'gitsh/interpreter'
require 'gitsh/version'
module Gitsh
class CLI
def initialize(opts={})
@env = opts.fetch(:env, Environment.new)
@... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/interpreter.rb | lib/gitsh/interpreter.rb | require 'rltk'
require 'gitsh/commands/noop'
require 'gitsh/error'
require 'gitsh/lexer'
require 'gitsh/parser'
module Gitsh
class Interpreter
def initialize(options)
@env = options.fetch(:env)
@lexer = options.fetch(:lexer, Lexer)
@parser = options.fetch(:parser, Parser)
@input_strategy ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/colors.rb | lib/gitsh/colors.rb | module Gitsh
module Colors
NONE = ''
CLEAR = "\033[00m"
BLACK_FG = "\033[30m"
RED_FG = "\033[31m"
GREEN_FG = "\033[32m"
YELLOW_FG = "\033[33m"
BLUE_FG = "\033[34m"
MAGENTA_FG = "\033[35m"
CYAN_FG = "\033[36m"
WHITE_FG = "\033[37m"
RED_BG = "\033[41m"
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/history.rb | lib/gitsh/history.rb | module Gitsh
class History
DEFAULT_HISTORY_FILE = "#{Dir.home}/.gitsh_history"
DEFAULT_HISTORY_SIZE = 500
def initialize(env, line_editor)
@env = env
@line_editor = line_editor
end
def load
File.read(history_file_path).lines.each do |command|
line_editor::HISTORY << com... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/git_command_list.rb | lib/gitsh/git_command_list.rb | module Gitsh
class GitCommandList
def initialize(env)
@env = env
end
def to_a
try_using(commands_from_list_cmds) do
try_using(commands_from_help('help -a --no-verbose')) do
try_using(commands_from_help('help -a'))
end
end
end
private
attr_accessor... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/error.rb | lib/gitsh/error.rb | module Gitsh
class Error < StandardError
end
class UnsetVariableError < Error
end
class NoInputError < Error
end
class ParseError < Error
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/arguments/subshell.rb | lib/gitsh/arguments/subshell.rb | require 'gitsh/capturing_environment'
module Gitsh
module Arguments
class Subshell
def initialize(command, options = {})
@command = command
end
def value(env)
capturing_env = CapturingEnvironment.new(env.clone)
command.execute(capturing_env)
strip_whitespace(cap... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/arguments/variable_argument.rb | lib/gitsh/arguments/variable_argument.rb | module Gitsh
module Arguments
class VariableArgument
def initialize(variable_name)
@variable_name = variable_name
end
def value(env)
env.fetch(variable_name)
end
def ==(other)
other.is_a?(self.class) && variable_name == other.variable_name
end
p... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/arguments/string_argument.rb | lib/gitsh/arguments/string_argument.rb | module Gitsh
module Arguments
class StringArgument
def initialize(value)
@raw_value = value
end
def value(_env)
raw_value
end
def ==(other)
other.is_a?(self.class) && raw_value == other.raw_value
end
protected
attr_reader :raw_value
e... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/arguments/composite_argument.rb | lib/gitsh/arguments/composite_argument.rb | module Gitsh
module Arguments
class CompositeArgument
def initialize(parts)
@parts = parts
end
def value(env)
parts.map { |part| part.value(env) }.join('')
end
def ==(other)
other.is_a?(self.class) && parts == other.parts
end
protected
at... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/input_strategies/file.rb | lib/gitsh/input_strategies/file.rb | require 'gitsh/error'
module Gitsh
module InputStrategies
class File
STDIN_PLACEHOLDER = '-'.freeze
def initialize(opts)
@env = opts[:env]
@path = opts.fetch(:path)
end
def setup
@file = open_file
rescue Errno::ENOENT
raise NoInputError, "#{path}: N... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/input_strategies/interactive.rb | lib/gitsh/input_strategies/interactive.rb | require 'gitsh/error'
require 'gitsh/file_runner'
require 'gitsh/history'
require 'gitsh/line_editor'
require 'gitsh/line_editor_history_filter'
require 'gitsh/prompter'
require 'gitsh/quote_detector'
require 'gitsh/tab_completion/facade'
require 'gitsh/terminal'
module Gitsh
module InputStrategies
class Interac... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/commands/lazy_command.rb | lib/gitsh/commands/lazy_command.rb | require 'gitsh/argument_list'
require 'gitsh/commands/git_command'
require 'gitsh/commands/internal_command'
require 'gitsh/commands/shell_command'
module Gitsh
module Commands
class LazyCommand
COMMAND_PREFIX_MATCHER = /^([:!])?(.+)$/
COMMAND_CLASS_BY_PREFIX = {
nil => Gitsh::Commands::GitCo... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/commands/tree.rb | lib/gitsh/commands/tree.rb | module Gitsh::Commands
module Tree
class Branch
def initialize(left, right)
@left = left
@right = right
end
private
attr_reader :left, :right
end
class Multi < Branch
def execute(env)
left.execute(env)
right.execute(env)
end
end
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/commands/noop.rb | lib/gitsh/commands/noop.rb | module Gitsh::Commands
class Noop
def execute(_env)
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/commands/internal_command.rb | lib/gitsh/commands/internal_command.rb | require 'gitsh/error'
module Gitsh::Commands
module InternalCommand
def self.new(command, arg_values)
command_class(command).new(command, arg_values)
end
def self.commands
COMMAND_CLASSES.keys.map { |key| ":#{key}" }
end
def self.command_class(command)
COMMAND_CLASSES.fetch(co... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/commands/git_command.rb | lib/gitsh/commands/git_command.rb | require 'shellwords'
require 'gitsh/shell_command_runner'
module Gitsh
module Commands
class GitCommand
def initialize(command, arg_values, options = {})
@command = command
@arg_values = arg_values
@shell_command_runner = options.fetch(
:shell_command_runner,
She... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/commands/shell_command.rb | lib/gitsh/commands/shell_command.rb | require 'gitsh/shell_command_runner'
module Gitsh
module Commands
class ShellCommand
SHELLWORDS_WHITELIST = 'A-Za-z0-9_\-.,:\/@\n'.freeze
GLOB_WHITELIST = '\*\[\]!\?\\\\'.freeze
SHELL_CHARACTER_FILTER = /([^#{SHELLWORDS_WHITELIST}#{GLOB_WHITELIST}])/
def initialize(command, arg_values, o... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/git_repository/status.rb | lib/gitsh/git_repository/status.rb | module Gitsh
class GitRepository
class Status
def initialize(status_porcelain, git_dir)
@status_porcelain = status_porcelain
@git_dir = git_dir
@initialized = File.exist?(git_dir)
end
def initialized?
@initialized
end
def has_untracked_files?
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/facade.rb | lib/gitsh/tab_completion/facade.rb | require 'gitsh/tab_completion/alias_expander'
require 'gitsh/tab_completion/automaton_factory'
require 'gitsh/tab_completion/command_completer'
require 'gitsh/tab_completion/context'
require 'gitsh/tab_completion/escaper'
require 'gitsh/tab_completion/variable_completer'
module Gitsh
module TabCompletion
class F... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/alias_expander.rb | lib/gitsh/tab_completion/alias_expander.rb | require 'gitsh/error'
require 'gitsh/tab_completion/tokens_to_words'
module Gitsh
module TabCompletion
class AliasExpander
def initialize(words, env)
@words = words
@env = env
end
def call
if expandable?
expanded_alias_words + words.drop(1)
else
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/tokens_to_words.rb | lib/gitsh/tab_completion/tokens_to_words.rb | module Gitsh
module TabCompletion
class TokensToWords
def self.call(tokens)
new(tokens).call
end
def initialize(tokens)
@tokens = tokens
end
def call
words
end
private
attr_reader :tokens
def words
token_groups.map do |toke... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/automaton.rb | lib/gitsh/tab_completion/automaton.rb | require 'set'
module Gitsh
module TabCompletion
class Automaton
def initialize(start_state)
@start_state = start_state
end
def completions(context, token)
match(context).flat_map { |state| state.completions(token) }.uniq
end
def match(tokens)
tokens.inject(... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/variable_completer.rb | lib/gitsh/tab_completion/variable_completer.rb | module Gitsh
module TabCompletion
class VariableCompleter
def initialize(line_editor, input, env)
@line_editor = line_editor
@input = input
@env = env
end
def call
line_editor.completion_append_character = completion_append_character
line_editor.completio... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl.rb | lib/gitsh/tab_completion/dsl.rb | require 'gitsh/tab_completion/dsl/lexer'
require 'gitsh/tab_completion/dsl/parser'
module Gitsh
module TabCompletion
module DSL
def self.load(path, start_state, env)
source = File.read(path)
tokens = Lexer.lex(source, path)
factory = Parser.parse(tokens, gitsh_env: env)
fact... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/automaton_factory.rb | lib/gitsh/tab_completion/automaton_factory.rb | require 'gitsh/tab_completion/automaton'
require 'gitsh/tab_completion/dsl'
module Gitsh
module TabCompletion
class AutomatonFactory
def self.build(env)
new(env).build
end
def initialize(env)
@env = env
end
def build
start_state = Automaton::State.new('star... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/context.rb | lib/gitsh/tab_completion/context.rb | require 'gitsh/lexer'
require 'gitsh/tab_completion/tokens_to_words'
module Gitsh
module TabCompletion
class Context
COMMAND_SEPARATORS = [
:AND, :OR, :SEMICOLON, :LEFT_PAREN, :SUBSHELL_START, :EOL,
].freeze
NOT_MEANINGFUL = [:EOS, :INCOMPLETE].freeze
def initialize(input)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/escaper.rb | lib/gitsh/tab_completion/escaper.rb | require 'gitsh/lexer'
module Gitsh
module TabCompletion
class Escaper
ESCAPABLES = {
nil => Gitsh::Lexer::UNQUOTED_STRING_ESCAPABLES,
'"' => Gitsh::Lexer::SOFT_STRING_ESCAPABLES,
"'" => Gitsh::Lexer::HARD_STRING_ESCAPABLES,
}.freeze
def initialize(line_editor)
@... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/command_completer.rb | lib/gitsh/tab_completion/command_completer.rb | module Gitsh
module TabCompletion
class CommandCompleter
def initialize(line_editor, prior_words, input, automaton, escaper)
@line_editor = line_editor
@prior_words = prior_words
@input = input
@automaton = automaton
@escaper = escaper
end
def call
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/visualization.rb | lib/gitsh/tab_completion/visualization.rb | require 'set'
require 'gitsh/tab_completion/automaton'
require 'gitsh/tab_completion/matchers/text_matcher'
module Gitsh
module TabCompletion
class Visualization
def initialize(automaton)
@automaton = automaton
end
def to_dot
%Q(digraph TabCompletion {
ranksep=3;
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/maybe_operation_factory.rb | lib/gitsh/tab_completion/dsl/maybe_operation_factory.rb | module Gitsh
module TabCompletion
module DSL
class MaybeOperationFactory
attr_reader :child
def initialize(child)
@child = child
end
def build(start_state, options = {})
end_state = child.build(start_state, options)
start_state.add_free_transit... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/parse_error.rb | lib/gitsh/tab_completion/dsl/parse_error.rb | require 'gitsh/error'
module Gitsh
module TabCompletion
module DSL
class ParseError < Gitsh::Error
TOKEN_TO_DESCRIPTION = {
BLANK: 'blank line',
INDENT: 'indent',
LEFT_PAREN: 'opening paren',
RIGHT_PAREN: 'closing paren',
MAYBE: 'operator (?)',
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/rule_set_factory.rb | lib/gitsh/tab_completion/dsl/rule_set_factory.rb | module Gitsh
module TabCompletion
module DSL
class RuleSetFactory
attr_reader :rules
def initialize(rules)
@rules = rules
end
def build(start_state)
rules.each { |rule| rule.build(start_state) }
end
end
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/choice_factory.rb | lib/gitsh/tab_completion/dsl/choice_factory.rb | require 'gitsh/tab_completion/automaton'
module Gitsh
module TabCompletion
module DSL
class ChoiceFactory
attr_reader :choices
def initialize(choices)
@choices = choices
end
def build(start_state, options = {})
end_state = options.fetch(:end_state) do
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/fallback_transition_factory.rb | lib/gitsh/tab_completion/dsl/fallback_transition_factory.rb | require 'gitsh/tab_completion/automaton'
module Gitsh
module TabCompletion
module DSL
class FallbackTransitionFactory
attr_reader :matcher
def initialize(matcher)
@matcher = matcher
end
def build(start_state, options = {})
end_state = options.fetch(:end... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/rule_factory.rb | lib/gitsh/tab_completion/dsl/rule_factory.rb | module Gitsh
module TabCompletion
module DSL
class RuleFactory
attr_reader :root, :options
def initialize(root, options)
@root = root
@options = options
end
def build(start_state)
root.build(start_state, known_options_factory: options)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/parser.rb | lib/gitsh/tab_completion/dsl/parser.rb | require 'rltk'
require 'gitsh/tab_completion/dsl/choice_factory'
require 'gitsh/tab_completion/dsl/concatenation_factory'
require 'gitsh/tab_completion/dsl/fallback_transition_factory'
require 'gitsh/tab_completion/dsl/parse_error'
require 'gitsh/tab_completion/dsl/maybe_operation_factory'
require 'gitsh/tab_completion... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/option_transition_factory.rb | lib/gitsh/tab_completion/dsl/option_transition_factory.rb | require 'gitsh/tab_completion/automaton'
require 'gitsh/tab_completion/matchers/unknown_option_matcher'
module Gitsh
module TabCompletion
module DSL
class OptionTransitionFactory
def build(start_state, options = {})
@start_state = start_state
@options = options
invoke... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/star_operation_factory.rb | lib/gitsh/tab_completion/dsl/star_operation_factory.rb | module Gitsh
module TabCompletion
module DSL
class StarOperationFactory
attr_reader :child
def initialize(child)
@child = child
end
def build(start_state, options = {})
child.build(start_state, options.merge(end_state: start_state))
end
end... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/text_transition_factory.rb | lib/gitsh/tab_completion/dsl/text_transition_factory.rb | require 'gitsh/tab_completion/automaton'
require 'gitsh/tab_completion/matchers/text_matcher'
module Gitsh
module TabCompletion
module DSL
class TextTransitionFactory
attr_reader :word
def initialize(word)
@word = word
end
def build(start_state, options = {})
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/plus_operation_factory.rb | lib/gitsh/tab_completion/dsl/plus_operation_factory.rb | module Gitsh
module TabCompletion
module DSL
class PlusOperationFactory
attr_reader :child
def initialize(child)
@child = child
end
def build(start_state, options = {})
end_state = child.build(start_state, options)
end_state.add_free_transition... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.