Sha256: a5dc8e884e0669b496ed6160aaaaf9574d3ed5555f92aa05b6df24a794d6e6ed

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

module Intent
  module Projects
    class Status
      def self.run(projects_dir)
        project_index = {}

        Dir["#{projects_dir}/*"].each do |project|
          if Dir.exists?(project) && Dir.exists?("#{project}/.git")
            Dir.chdir(project)
            git_output = `git status`
            project_name = Pathname.new(project).basename

            status = {
              untracked_files: git_output.include?('Untracked files'),
              unstaged_edits: git_output.include?('Changes not staged for commit')
            }

            if status[:untracked_files] || status[:unstaged_edits]
              project_index[project_name] = status
            end
          end
        end

        pastel = Pastel.new

        project_index.each do |key, value|
          result = []
          if value[:untracked_files]
            result << pastel.red('untracked files')
          end
          if value[:unstaged_edits]
            result << pastel.red('unstaged edits')
          end
          puts "#{pastel.bold('+')}#{pastel.bold(key)} contains #{result.join(' and ')}."
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
intent-0.8.1 lib/intent/verbs/status.rb
intent-0.8.0 lib/intent/verbs/status.rb
intent-0.7.1 lib/intent/verbs/status.rb
intent-0.7.0 lib/intent/verbs/status.rb
intent-0.6.0 lib/intent/projects/status.rb
intent-0.5.5 lib/intent/projects/status.rb
intent-0.5.4 lib/intent/projects/status.rb
intent-0.5.3 lib/intent/projects/status.rb
intent-0.5.2 lib/intent/projects/status.rb
intent-0.5.1 lib/intent/projects/status.rb