Sha256: 558a69bd178c7080d06011f9b8cdf006711b9601674e68ddae1608b9e0d230bb

Contents?: true

Size: 1.59 KB

Versions: 13

Compression:

Stored size: 1.59 KB

Contents

# Copyright (C) 2020  Chris Liaw <chrisliaw@antrapol.com>
# Author: Chris Liaw <chrisliaw@antrapol.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.



require 'fileutils'

require_relative 'global'

module GitCli
  module Init

    def init(path)
      # from Core module
      gpath = exe_path 

      cmd = []
      #cmd << "cd #{File.expand_path(path)}"
      #cmd << "&&"
      cmd << gpath
      cmd << "init"
      cmd << File.expand_path(path)
     
      cmdln = cmd.join(" ")

      log_debug "Init : #{cmdln} " 

      os_exec(cmdln) do |st, res|
        [st.success?, res.strip]
      end
      
    end # init

    def reset(path)
      
      raise_if_empty(path, "Path should not be empty for reset operation", GitCliException)

      if File.exist?(path)
        Dir.entries(path).each do |f|
          if f == ".git"
            log_debug ".git directory found."
            FileUtils.rm_rf(f)
            log_debug ".git directory deleted"
            break
          end
        end
      end 

    end # reset

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
git_cli-0.11.4 lib/git_cli/init.rb
git_cli-0.11.3 lib/git_cli/init.rb
git_cli-0.11.2 lib/git_cli/init.rb
git_cli-0.11.0 lib/git_cli/init.rb
git_cli-0.9.0 lib/git_cli/init.rb
git_cli-0.8.0 lib/git_cli/init.rb
git_cli-0.7.0 lib/git_cli/init.rb
git_cli-0.6.0 lib/git_cli/init.rb
git_cli-0.5.0 lib/git_cli/init.rb
git_cli-0.4.0 lib/git_cli/init.rb
git_cli-0.3.0 lib/git_cli/init.rb
git_cli-0.2.0 lib/git_cli/init.rb
git_cli-0.1.0 lib/git_cli/init.rb