Class: AvoDeploy::ScmProvider::GitScmProvider
- Inherits:
-
ScmProvider
- Object
- ScmProvider
- AvoDeploy::ScmProvider::GitScmProvider
- Defined in:
- lib/avodeploy/scm_provider/git_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) ⇒ GitScmProvider
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) ⇒ GitScmProvider
Initializes the provider
@param env [TaskExecutionEnvironment] Environment for the commands to be executed in
26 27 28 |
# File 'lib/avodeploy/scm_provider/git_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 46 47 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 36 def checkout_from_remote(url, local_dir, branch, tag = nil) res = @env.command("git clone --recursive #{url} #{local_dir}") raise RuntimeError, "Could not clone from git url #{url}" unless res.retval == 0 branch = tag if tag.nil? == false @env.chdir(local_dir) res = @env.command("git checkout #{branch}") @env.chdir('../') raise RuntimeError, "could not switch to branch #{branch}" unless res.retval == 0 end |
#cli_utils ⇒ Array
Returns the scm tools that have to be installed on specific systems
88 89 90 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 88 def cli_utils ['git', 'awk', 'grep'] end |
#diff_files_between_revisions(rev1, rev2) ⇒ Array
Finds files that differ between two revisions and returns them as a array
64 65 66 67 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 64 def diff_files_between_revisions(rev1, rev2) res = @env.command("git diff --name-only #{rev1} #{rev2}") res.stdout.lines end |
#revision ⇒ String
Returns the current revision of the working copy
52 53 54 55 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 52 def revision res = @env.command('git rev-parse HEAD') res.stdout.gsub("\n", '') end |
#scm_files ⇒ Array
Returns scm files to be executed in the deployment process
81 82 83 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 81 def scm_files ['.git', '.gitignore'] end |
#unknown_files_in_workdir ⇒ Array
Finds files unknown file in the working directory and returns them as a array
73 74 75 76 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 73 def unknown_files_in_workdir res = @env.command("git status -s | grep '^??' | awk '/^?? (.*)$/ {print $2}'") res.stdout.lines end |