Class: AvoDeploy::ScmProvider::GitScmProvider
- Inherits:
-
Object
- Object
- AvoDeploy::ScmProvider::GitScmProvider
- Defined in:
- lib/avodeploy/scm_provider/git_scm_provider.rb
Instance Method Summary collapse
-
#checkout_from_remote(url, local_dir, branch) ⇒ 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.
-
#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.
Constructor Details
#initialize(env) ⇒ GitScmProvider
Initializes the provider
@param env [TaskExecutionEnvironment] Environment for the commands to be executed in
26 27 28 29 30 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 26 def initialize(env) raise ArgumentError, "env must be a TaskExecutionEnvironment" unless env.kind_of?(AvoDeploy::Task::TaskExecutionEnvironment) @env = env end |
Instance Method Details
#checkout_from_remote(url, local_dir, branch) ⇒ Object
Checks out repository code from a system and switches to the given branch
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 37 def checkout_from_remote(url, local_dir, branch) res = @env.command("git clone #{url} #{local_dir}") raise RuntimeError, "Could not clone from git url #{url}" unless res.retval == 0 @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
67 68 69 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 67 def cli_utils [ 'git' ] end |
#revision ⇒ String
Returns the current revision of the working copy
51 52 53 54 55 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 51 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
60 61 62 |
# File 'lib/avodeploy/scm_provider/git_scm_provider.rb', line 60 def scm_files [ '.git', '.gitignore' ] end |