class Fanforce::AppFactory::CLI::Git include Fanforce::AppFactory::CLI::Utils attr_reader :app def initialize(app) @app = app end def setup if init.include?('Reinitialized') puts "#{'Found '.format(:green,:bold)}" + 'existing local repository' else puts "#{'Initialized '.format(:green,:bold)}" + 'local repository' add_files and log '- git add .' make_first_commit and log '- git commit -m "initial fanforce commit"' puts "#{'Created '.format(:green,:bold)}" + 'initial fanforce commit' end end def self.status_table_header(app_column_width) sprintf('%-12s %-50s %85s', 'GIT STATUS', 'APP NAME', 'STATS OVERVIEW').format(:bold) end def status_row(app_column_width) sprintf("%s%-12s#{fmt_end} %-50s %28s %28s %28s", fmt_start(is_committed ? :green : :red), (is_committed ? 'Committed' : 'Uncommitted'), app.name, *changed_stats ) end def is_committed `git status`.include?('nothing to commit') ? true : false end def changed_stats `git diff --stat`.split("\n").last.split(', ') end private def init response = `git init` `git config core.fileMode false` return response end def add_files `git add .` end def make_first_commit `git commit -m "initial fanforce commit"` end end