Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,514 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.swp | ||
*.un~ | ||
.idea | ||
__pycache__ | ||
/MANIFEST | ||
/dist | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include COPYING | ||
include README.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Castor | ||
====== | ||
|
||
Provides a way to assemble various Git repositories into one. It's like submodules that don't suck. | ||
|
||
Use case: stitch together Wordpress with some themes and plugins before deploying. | ||
|
||
Usage | ||
~~~~~ | ||
|
||
First, you need to create your Castor repository. The following command will create an new Git | ||
repository containing an empty ``Castorfile`` and a pre-initialized .gitignore. | ||
|
||
.. code-block:: | ||
castor init my-proj | ||
Then, you need to edit your ``Castorfile``. It might look like | ||
|
||
.. code-block:: | ||
{ | ||
"lodge": [ | ||
{ | ||
"target": "/", | ||
"version": "1.6.1.0", | ||
"repo": "https://github.com/PrestaShop/PrestaShop.git", | ||
"type": "git" | ||
}, | ||
{ | ||
"target": "/themes/my-prestashop-theme", | ||
"version": "e0e7c15789e6ff674cd75cb24981155441c3df09", | ||
"repo": "git@bitbucket.org:activkonnect/my-prestashop-theme.git", | ||
"type": "git" | ||
}, | ||
{ | ||
"target": "/.htaccess", | ||
"type": "file", | ||
"source": "files/htaccess" | ||
} | ||
] | ||
} | ||
Your ``Castorfile`` being filled up, you can now apply it | ||
|
||
.. code-block:: | ||
castor apply | ||
This will automatically create your repositories hierarchy, checkout submodules, etc. The root of | ||
this hierarchy will be the ``lodge`` directory. | ||
|
||
Now you can freeze your project into a git-free, commitable and deployable tree of source code. | ||
This will go into the ``dam`` directory. | ||
|
||
.. code-block:: | ||
castor freeze | ||
You can use the ``lodge`` as your working directory during development. If you make updates to the | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env python3 | ||
# vim: fileencoding=utf-8 tw=100 expandtab ts=4 sw=4 : | ||
# | ||
# Castor | ||
# (c) 2015 ActivKonnect | ||
# Rémy Sanchez <remy.sanchez@activkonnect.com> | ||
|
||
import argparse | ||
import sys | ||
|
||
from castor.repo import CastorException, init, find_repo, Castor | ||
|
||
|
||
def parse_cli(): | ||
p = argparse.ArgumentParser(description='Castor is a tool to manage assembly of various Git ' | ||
'repositories into a single deployable source tree.') | ||
s = p.add_subparsers(help='Action', dest='action') | ||
|
||
a_init = s.add_parser('init', help='Initializes a directory') | ||
a_init.add_argument('directory', type=str, default='.', nargs='?', help='Directory to ' | ||
'initialize (defaults ' | ||
'to current directory)') | ||
|
||
s.add_parser('apply', help='Apply the Castorfile') | ||
s.add_parser('freeze', help='Report current Git commits to Castorfile, assemble all files in ' | ||
'the dam directory and add them to the Git index.') | ||
|
||
r = p.parse_args() | ||
|
||
if r.action is None: | ||
p.print_help() | ||
sys.exit(1) | ||
|
||
return r | ||
|
||
|
||
def make_castor(): | ||
root = find_repo('.') | ||
|
||
if root is None: | ||
raise CastorException('You are not in a Castor repository') | ||
|
||
return Castor(root) | ||
|
||
|
||
def do_init(directory): | ||
init(directory) | ||
|
||
|
||
def do_apply(): | ||
make_castor().apply() | ||
|
||
|
||
def do_freeze(): | ||
make_castor().freeze() | ||
|
||
|
||
def main(): | ||
parsed = vars(parse_cli()) | ||
action = parsed.pop('action') | ||
|
||
try: | ||
globals()['do_{}'.format(action)](**parsed) | ||
except KeyboardInterrupt: | ||
print('kthx, bye') | ||
sys.exit(1) | ||
except CastorException as e: | ||
sys.stderr.write('Error: {}\n'.format(e)) | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
jsonschema>=2.5.1,<2.6.0 | ||
GitPython>=1.0.1,<1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
# vim: fileencoding=utf-8 tw=100 expandtab ts=4 sw=4 : | ||
# | ||
# (c) 2015 ActivKonnect | ||
|
||
import os | ||
import codecs | ||
from distutils.core import setup | ||
|
||
|
||
with codecs.open(os.path.join(os.path.dirname(__file__), 'README.rst'), 'r') as readme: | ||
README = readme.read() | ||
|
||
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) | ||
|
||
setup( | ||
name='castor', | ||
version='0.1.0', | ||
scripts=['bin/castor'], | ||
packages=['castor'], | ||
package_dir={'': 'src'}, | ||
include_package_data=True, | ||
license='WTFPL', | ||
description='Assemble Git repos into a deployable tree of code.', | ||
long_description=README, | ||
url='https://github.com/ActivKonnect/castor', | ||
author='Rémy Sanchez', | ||
author_email='remy.sanchez@activkonnect.com', | ||
classifiers=[ | ||
'Intended Audience :: Developers', | ||
'License :: Other/Proprietary License', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.3', | ||
'Programming Language :: Python :: 3.4', | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# vim: fileencoding=utf-8 tw=100 expandtab ts=4 sw=4 : | ||
# | ||
# Castor | ||
# (c) 2015 ActivKonnect | ||
# Rémy Sanchez <remy.sanchez@activkonnect.com> | ||
|
||
|
||
from .repo import Castor |
Oops, something went wrong.