Class: Avocado::GitScmProvider
- Inherits:
-
Object
- Object
- Avocado::GitScmProvider
- Defined in:
- lib/avocado/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
25 26 27 28 29 |
# File 'lib/avocado/scm_provider/git_scm_provider.rb', line 25 def initialize(env) raise ArgumentError, "env must be a TaskExecutionEnvironment" unless env.kind_of?(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
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/avocado/scm_provider/git_scm_provider.rb', line 36 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
66 67 68 |
# File 'lib/avocado/scm_provider/git_scm_provider.rb', line 66 def cli_utils [ 'git' ] end |
#revision ⇒ String
Returns the current revision of the working copy
50 51 52 53 54 |
# File 'lib/avocado/scm_provider/git_scm_provider.rb', line 50 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
59 60 61 |
# File 'lib/avocado/scm_provider/git_scm_provider.rb', line 59 def scm_files [ '.git', '.gitignore' ] end |