Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Xowap committed Sep 21, 2015
2 parents 27893e6 + 3c32f89 commit fbc6be0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
13 changes: 12 additions & 1 deletion README.rst
Expand Up @@ -17,6 +17,12 @@ repository containing an empty ``Castorfile`` and a pre-initialized .gitignore.
Then, you need to edit your ``Castorfile``. It might look like

Note
++++

``post_freeze`` array is optional. It must be an array, each command will be executed
on the ``target`` directory after executing ``castor freeze``.

.. code-block::
{
Expand All @@ -31,7 +37,10 @@ Then, you need to edit your ``Castorfile``. It might look like
"target": "/themes/my-prestashop-theme",
"version": "e0e7c15789e6ff674cd75cb24981155441c3df09",
"repo": "git@bitbucket.org:activkonnect/my-prestashop-theme.git",
"type": "git"
"type": "git",
"post_freeze": [
"composer update --no-dev"
]
},
{
"target": "/.htaccess",
Expand Down Expand Up @@ -61,3 +70,5 @@ You can use the ``lodge`` as your working directory during development. If you m
code, you can commit in the git repos. If you simply want to update upstream code, check out the new
tag/commit you want to use. Then you can use ``castor freeze`` again, and it will update the
``Castorfile`` automatically with the latest Git HEADs, as well as the ``dam`` directory.


2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -22,7 +22,7 @@

setup(
name='castor',
version='0.2.0',
version='0.2.1',
scripts=['bin/castor'],
packages=['castor'],
package_dir={'': 'src'},
Expand Down
17 changes: 17 additions & 0 deletions src/castor/repo.py
Expand Up @@ -5,6 +5,8 @@
# Rémy Sanchez <remy.sanchez@activkonnect.com>

import json
import shlex
import subprocess
from tarfile import TarFile
from tempfile import NamedTemporaryFile
from shutil import copyfile, rmtree
Expand Down Expand Up @@ -66,6 +68,12 @@
'version': {
'type': 'string',
},
'post_freeze': {
'type': 'array',
'items': {
'type': 'string',
}
},
},
'required': ['target', 'type', 'repo', 'version'],
'additionalProperties': False,
Expand Down Expand Up @@ -343,6 +351,15 @@ def gather_dam(self):
if target['type'] == 'file':
self.apply_file(target['source'], self.target_dam_path(target))

for target in self.git_targets:
if 'post_freeze' in target:
dam_target = self.target_dam_path(target)
print('Executing post freeze for target {}'.format(target['target']))

for cl in target['post_freeze']:
print(cl)
subprocess.Popen(shlex.split(cl), cwd=dam_target).wait()

def freeze(self):
"""
The goal is to update current versions to the current Git HEADs, and gather all the files
Expand Down
5 changes: 4 additions & 1 deletion tests/assets/test1/Castorfile
Expand Up @@ -15,7 +15,10 @@
"target": "/modules/test",
"type": "git",
"repo": "https://bitbucket.org/activkonnect/castor-test-2.git",
"version": "tag1"
"version": "tag1",
"post_freeze": [
"touch foo"
]
}
]
}
9 changes: 9 additions & 0 deletions tests/repo.py
Expand Up @@ -229,6 +229,7 @@ def test_gather_dam(self):
self.assertEqual(dam_files, {
'test.txt',
'modules/test/youpi.txt',
'modules/test/foo',
'.htaccess',
})

Expand Down Expand Up @@ -258,6 +259,14 @@ def test_freeze(self):
with open(path.join(self.test_root, 'dam', 'test.txt')) as f:
self.assertEqual('Saluton', f.read())

def test_post_freeze(self):
c = Castor(self.test_root)
c.apply()

c.freeze()

self.assertTrue(path.exists(path.join(self.test_root, 'dam', 'modules', 'test', 'foo')))

def test_freeze_files(self):
c = Castor(self.test_root)
c.apply()
Expand Down

0 comments on commit fbc6be0

Please sign in to comment.