summaryrefslogtreecommitdiff
path: root/ick
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-05-25 19:52:46 +0300
committerLars Wirzenius <liw@liw.fi>2015-05-25 21:45:41 +0300
commit8ccb8ee299e3822e42564cae36e634af5ae6f1f3 (patch)
tree685ed52592531f307d89b7de0ce51e7e24c4b4a9 /ick
parent1e11ba1a9519afe2824a8a2be81b12ec086a2e9d (diff)
downloadick-8ccb8ee299e3822e42564cae36e634af5ae6f1f3.tar.gz
Add GitClone
Diffstat (limited to 'ick')
-rwxr-xr-xick22
1 files changed, 10 insertions, 12 deletions
diff --git a/ick b/ick
index 0265e2d..eb1da01 100755
--- a/ick
+++ b/ick
@@ -83,11 +83,14 @@ class Ick(cliapp.Application):
self.logger.log(
'Building project {project_name}', project_name=project_name)
- git_dir = self.get_git_dir(statedir, project_name)
- self.clone_or_update_git_repository_locally(
- git_dir, project['git'], project['branch'])
+ clone = icklib.GitClone()
+ clone.set_dirname(self.get_git_dir(statedir, project_name))
+ clone.set_url(project['git'])
+ clone.sync_from_url()
+ clone.checkout(project['branch'])
+
meta = BuildMetadata()
- meta.commit = self.get_head_commit(git_dir)
+ meta.commit = clone.get_HEAD_commit()
if not self.needs_to_be_built(statedir, project_name, meta.commit):
with self.logger:
@@ -98,7 +101,7 @@ class Ick(cliapp.Application):
build_dir = self.get_next_build_dir(statedir, project_name)
for target in targets:
- self.build_on_target(project_name, project, target, git_dir)
+ self.build_on_target(project_name, project, target, clone)
self.save_build_metadata(build_dir, meta)
def needs_to_be_built(self, statedir, project_name, current_commit):
@@ -139,21 +142,16 @@ class Ick(cliapp.Application):
def get_git_dir(self, statedir, project_name):
return os.path.join(statedir, project_name, 'git')
- def clone_or_update_git_repository_locally(self, git_dir, url, branch):
- cliapp.runcmd(['rm', '-rf', git_dir])
- cliapp.runcmd(
- ['git', 'clone', '--verbose', '--branch', branch, url, git_dir])
-
def get_head_commit(self, git_dir):
output = cliapp.runcmd(['git', 'rev-parse', 'HEAD'], cwd=git_dir)
return output.strip()
- def build_on_target(self, project_name, project, target, git_dir):
+ def build_on_target(self, project_name, project, target, clone):
with self.logger:
self.logger.log(
'Building {project_name} on {target_name}',
project_name=project_name, target_name=target.name)
- remote_git_dir = self.rsync_to_target(git_dir, target)
+ remote_git_dir = self.rsync_to_target(clone.dirname, target)
try:
for command in project.get('commands', []):
self.run_on_target(target, command, remote_git_dir)