Skip to content

Commit

Permalink
Merge 212dba2 into 3cca836
Browse files Browse the repository at this point in the history
  • Loading branch information
JrGoodle committed Jan 5, 2016
2 parents 3cca836 + 212dba2 commit add4e9a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions clowder/fork.py
@@ -0,0 +1,17 @@
"""Representation of clowder.yaml fork"""

class Fork(object):
"""clowder.yaml fork class"""

def __init__(self, name, path, remote):
self.name = name
self.path = path
self.remote = remote

def fetch(self):
"""Fetch remote data from fork"""
# git_fetch_fork(path, remote)

def get_yaml(self):
"""Return python object representation for saving yaml"""
return {'name': self.name, 'remote': self.remote}
11 changes: 11 additions & 0 deletions clowder/project.py
@@ -1,6 +1,7 @@
"""Representation of clowder.yaml project"""
import os, subprocess
from termcolor import colored, cprint
from clowder.fork import Fork
from clowder.utility.clowder_utilities import (
format_project_string,
format_ref_string,
Expand Down Expand Up @@ -58,6 +59,11 @@ def __init__(self, root_directory, project, defaults, sources):

self.url = self.source.get_url_prefix() + self.name + ".git"

self.forks = []
if 'forks' in project:
for fork in project['forks']:
self.forks.append(Fork(fork['name'], self.path, fork['remote']))

def exists(self):
"""Check if project exists on disk"""
path = os.path.join(self.full_path(), '.git')
Expand All @@ -69,9 +75,11 @@ def full_path(self):

def get_yaml(self):
"""Return python object representation for saving yaml"""
forks_yaml = [f.get_yaml() for f in self.forks]
return {'name': self.name,
'path': self.path,
'depth': self.depth,
'forks': forks_yaml,
'ref': git_current_sha(self.full_path()),
'remote': self.remote_name,
'source': self.source.name}
Expand Down Expand Up @@ -104,6 +112,9 @@ def herd(self):
else:
print('Unknown ref ' + self.ref)

for fork in self.forks:
fork.fetch()

def is_dirty(self):
"""Check if project is dirty"""
return git_is_dirty(self.full_path())
Expand Down
4 changes: 4 additions & 0 deletions clowder/utility/clowder_utilities.py
Expand Up @@ -74,8 +74,12 @@ def validate_yaml(parsed_yaml):
for project in group['projects']:
project['name']
project['path']
# for fork in project['forks']:
# fork['name']
# fork['remote']
except:
print('')
clowder_output = colored('clowder.yaml', 'cyan')
print(clowder_output + ' appears to be invalid')
print('')
sys.exit(1)

0 comments on commit add4e9a

Please sign in to comment.