Class: AvoDeploy::ScmProvider::BzrScmProvider
- Inherits:
-
ScmProvider
- Object
- ScmProvider
- AvoDeploy::ScmProvider::BzrScmProvider
- Defined in:
- lib/avodeploy/scm_provider/bzr_scm_provider.rb
Instance Method Summary collapse
-
#checkout_from_remote(url, local_dir, branch, tag = nil) ⇒ Object
Checks out repository code from a system and switches to the given branch.
-
#cli_utils ⇒ Array
Returns the scm tools that have to be installed on specific systems.
-
#diff_files_between_revisions(rev1, rev2) ⇒ Array
Finds files that differ between two revisions and returns them as a array.
-
#initialize(env) ⇒ BzrScmProvider
constructor
Initializes the provider.
-
#revision ⇒ String
Returns the current revision of the working copy.
-
#scm_files ⇒ Array
Returns scm files to be executed in the deployment process.
-
#unknown_files_in_workdir ⇒ Array
Finds files unknown file in the working directory and returns them as a array.
Constructor Details
#initialize(env) ⇒ BzrScmProvider
Initializes the provider
@param env [TaskExecutionEnvironment] Environment for the commands to be executed in
26 27 28 |
# File 'lib/avodeploy/scm_provider/bzr_scm_provider.rb', line 26 def initialize(env) super(env) end |
Instance Method Details
#checkout_from_remote(url, local_dir, branch, tag = nil) ⇒ Object
Checks out repository code from a system and switches to the given branch
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/avodeploy/scm_provider/bzr_scm_provider.rb', line 36 def checkout_from_remote(url, local_dir, branch, tag = nil) cmd = "bzr co --lightweight #{url} #{local_dir}" if tag.nil? == false cmd += " -r tag:#{tag}" end res = @env.command(cmd) raise RuntimeError, "Could not checkout from bzr url #{url}" unless res.retval == 0 end |
#cli_utils ⇒ Array
Returns the scm tools that have to be installed on specific systems
105 106 107 |
# File 'lib/avodeploy/scm_provider/bzr_scm_provider.rb', line 105 def cli_utils ['bzr'] end |
#diff_files_between_revisions(rev1, rev2) ⇒ Array
Finds files that differ between two revisions and returns them as a array
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/avodeploy/scm_provider/bzr_scm_provider.rb', line 63 def diff_files_between_revisions(rev1, rev2) # same revision, nothing changed if rev1 == rev2 return [] end # exclude rev1 itself rev1 = rev1.to_i + 1 res = @env.command("bzr log -r#{rev1}..#{rev2} -v --short") files = [] res.stdout.lines.each do |line| line.strip! next unless line.start_with?('A') || line.start_with?('M') files << line[3, line.length] end files end |
#revision ⇒ String
Returns the current revision of the working copy
50 51 52 53 54 |
# File 'lib/avodeploy/scm_provider/bzr_scm_provider.rb', line 50 def revision res = @env.command('bzr revno --tree') res.stdout.gsub("\n", '') end |
#scm_files ⇒ Array
Returns scm files to be executed in the deployment process
98 99 100 |
# File 'lib/avodeploy/scm_provider/bzr_scm_provider.rb', line 98 def scm_files ['.bzr', '.bzrignore'] end |
#unknown_files_in_workdir ⇒ Array
Finds files unknown file in the working directory and returns them as a array
90 91 92 93 |
# File 'lib/avodeploy/scm_provider/bzr_scm_provider.rb', line 90 def unknown_files_in_workdir res = @env.command("bzr status --short | grep '^? ' | awk '/^? (.*)$/ {print $2}'") res.stdout.lines end |