src/metrics_calc/metrics_calc.rb
# Ensure the project can be cloned properly.
Ensure the project can be cloned properly.
Ensure the project can be cloned properly .
def verifyGitHubProject(folder, repo_owner, repo_name)
    if !Dir.exists?("#{folder}#{repo_name}")
        Dir.chdir(folder)
        %x(git clone #{getCloneString(repo_owner, repo_name)})
        Dir.chdir(repo_name)
    else
        Dir.chdir("#{folder}#{repo_name}")
        if %x(git remote show origin | grep #{getCloneString(repo_owner, repo_name)}).empty?
            puts "Folder for the project already exists within #{folder} would you like to delete it? (y/N)"
            answer = gets.chomp!
            if answer.downcase == "y"
                FileUtils.rm_rf("#{folder}#{repo_name}")
                verifyGitHubProject(folder, repo_owner, repo_name)
            else
                return false
            end
        else
            if %x(git status --porcelain | tr -d '??').empty?
                return true
            else
                puts "The project has pending changes resolve them."
                return false
            end
        end
    end
    return true
end
def verifyGitHubProject ( folder , repo_owner , repo_name ) if ! Dir . exists? ( "#{folder}#{repo_name}" ) Dir . chdir ( folder ) %x( git clone  #{ getCloneString ( repo_owner , repo_name ) } ) Dir . chdir ( repo_name ) else Dir . chdir ( "#{folder}#{repo_name}" ) if %x( git remote show origin | grep  #{ getCloneString ( repo_owner , repo_name ) } ) . empty? puts "Folder for the project already exists within #{folder} would you like to delete it? (y/N)" answer = gets . chomp! if answer . downcase == "y" FileUtils . rm_rf ( "#{folder}#{repo_name}" ) verifyGitHubProject ( folder , repo_owner , repo_name ) else return false end else if %x( git status --porcelain | tr -d '??' ) . empty? return true else puts "The project has pending changes resolve them." return false end end end return true end
Ensure the project can be cloned properly.
Ensure the project can be cloned properly .
# Clone the project # Verify the project is actually the project we are looking for # Folder exists but is not the repository delete? #Delete the folder                # Clone it again # Do not delete # Folder is a clone # Nothing is pending proceed
folder
<not_specific>
repo_owner
<not_specific>
repo_name
<not_specific>