Sha256: 23dc4bd5a201f9926098ae617943d4cb1d37f70f4432bd0970fe1b117cb7d1b1

Contents?: true

Size: 1.49 KB

Versions: 72

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require_relative "../base"

module Neetob
  class CLI
    module FetchorupdateRepos
      class Execute < Base
        attr_accessor :sandbox, :repos

        def initialize(sandbox = false, repos = ["*"])
          super()
          @sandbox = sandbox
          @repos = repos
        end

        def run
          neeto_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
          neeto_repos.each do |repo|
            repo_name = repo.split("/").last
            ui.info("\nWorking on #{repo_name}\n")
            if directory_exists(repo_name)
              checkout_to_main_and_fetch_commits(repo_name)
            else
              clone_repo(repo_name)
            end
          end
        end

        def directory_exists(repo_name)
          File.directory?(repo_name)
        end

        def checkout_to_main_and_fetch_commits(repo_name)
          %x[ cd #{repo_name} && git checkout main && git pull origin main ]
          if $?.success?
            puts "------Successfully pulled main branch of #{repo_name}------"
          else
            puts "------Unable to pull the main branch of #{repo_name} due to conflicts------"
          end
        end

        def clone_repo(repo_name)
          `git clone git@github.com:bigbinary/#{repo_name}.git`
          if $?.success?
            puts "------Done cloning #{repo_name}------"
          else
            puts "------Failed cloning #{repo_name}------"
          end
        end
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
neetob-0.5.35 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.34 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.33 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.32 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.31 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.30 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.29 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.28 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.27 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.26 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.25 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.24 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.23 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.22 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.21 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.20 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.19 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.18 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.17 lib/neetob/cli/fetchorupdate_repos/execute.rb
neetob-0.5.16 lib/neetob/cli/fetchorupdate_repos/execute.rb