Module: RuVim::Git::Status
- Defined in:
- lib/ruvim/git/status.rb
Defined Under Namespace
Modules: HandlerMethods
Class Method Summary collapse
-
.parse_filename(line) ⇒ Object
Extract filename from a git status output line.
-
.run(file_path) ⇒ Object
Run git status.
Class Method Details
.parse_filename(line) ⇒ Object
Extract filename from a git status output line. Returns relative path or nil.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruvim/git/status.rb', line 25 def parse_filename(line) stripped = line.to_s.strip case stripped when /\A(?:modified|new file|deleted|renamed|copied|typechange):\s+(.+)/ $1.strip when /\A(\S.+)/ # Untracked file lines (no prefix keyword) path = $1.strip # Skip section headers and hints return nil if path.start_with?("(") return nil if path.match?(/\A[A-Z]/) path else nil end end |
.run(file_path) ⇒ Object
Run git status. Returns [lines, root, error_message].
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ruvim/git/status.rb', line 12 def run(file_path) root, err = Git.repo_root(file_path) return [nil, nil, err] unless root out, err, status = Open3.capture3("git", "status", chdir: root) unless status.success? return [nil, nil, err.strip] end [out.lines(chomp: true), root, nil] end |