Class: PmdTester::ProjectBuilder
- Inherits:
-
Object
- Object
- PmdTester::ProjectBuilder
- Includes:
- PmdTester
- Defined in:
- lib/pmdtester/builders/project_builder.rb
Overview
Clones and builds the projects, that are configured in the project-list.xml
Constant Summary
Constants included from PmdTester
BASE, PATCH, PR_NUM_ENV_VAR, VERSION
Instance Method Summary collapse
- #build_projects ⇒ Object
- #clone_projects ⇒ Object
-
#initialize(projects) ⇒ ProjectBuilder
constructor
A new instance of ProjectBuilder.
Methods included from PmdTester
Constructor Details
#initialize(projects) ⇒ ProjectBuilder
Returns a new instance of ProjectBuilder.
11 12 13 |
# File 'lib/pmdtester/builders/project_builder.rb', line 11 def initialize(projects) @projects = projects end |
Instance Method Details
#build_projects ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pmdtester/builders/project_builder.rb', line 51 def build_projects logger.info 'Building projects started' @projects.each do |project| path = project.clone_root_path Dir.chdir(path) do progress_logger = SimpleProgressLogger.new("building #{project.name} in #{path}") progress_logger.start prepare_project(project) progress_logger.stop end logger.info "Building #{project.name} completed" end logger.info 'Building projects completed' end |
#clone_projects ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pmdtester/builders/project_builder.rb', line 15 def clone_projects logger.info 'Cloning projects started' @projects.each do |project| logger.info "Start cloning #{project.name} repository" path = project.clone_root_path raise "Unsupported project type '#{project.type}' - only git is supported" unless project.type == 'git' if File.exist?(path) logger.warn "Skipping clone, project path #{path} already exists" else # Don't download whole history. This just fetches HEAD, the correct ref is fetched below. clone_cmd = "git clone --single-branch --depth 1 #{project.connection} #{path}" Cmd.execute_successfully(clone_cmd) end Dir.chdir(path) do # this works with tags, branch names and (full-length) hashes # first move to a different (temporary) branch, in case we are already on the branch that we want to update Cmd.execute_successfully('git checkout -b fetched/temp') # fetches any new commits. Could also be a tag. Cmd.execute_successfully("git fetch --depth 1 origin #{project.tag}") # update the branch to work on based on the new fetch. Creates a new branch if it doesn't exist already Cmd.execute_successfully("git branch --force fetched/#{project.tag} FETCH_HEAD") # checkout the updated branch Cmd.execute_successfully("git checkout fetched/#{project.tag}") # remove the temporary branch Cmd.execute_successfully('git branch -D fetched/temp') end logger.info "Cloning #{project.name} completed" end logger.info 'Cloning projects completed' end |