Giter Club home page Giter Club logo

modgit's Introduction

Deploy multiple Git repositories in an unique folder

modgit is a shell script for deploying multiple Git repositories in root folder of any project, which is not possible with default git submodule command. A common use case would be the easy installation of Magento modules that need to be deployed in root folder.

Installation

curl installation

$ curl https://raw.githubusercontent.com/jreinke/modgit/master/modgit > modgit
$ chmod +x modgit
$ mv modgit /usr/local/bin

wget installation

$ wget -O modgit https://raw.githubusercontent.com/jreinke/modgit/master/modgit
$ chmod +x modgit
$ mv modgit /usr/local/bin

Manual download

  • Download shell script here
  • Copy modgit file to /usr/local/bin (or any folder in your $PATH)
  • Run chmod +x modgit

Usage

Install a module

$ cd /path/to/project
$ modgit init
$ modgit add [-n] [-t tag_name] [-b branch_name] <module> <git_repository>

Update a module

$ modgit up [-n] <module>

Update all modules

$ modgit up-all [-n]

Remove a module

$ modgit rm [-n] <module>

Remove all modules

$ modgit rm-all [-n]

List installed modules

$ modgit ls

Show information about an installed module

$ modgit info <module>

Show deployed files of an installed module

$ modgit files <module>

Show help

$ modgit help

Advanced usage

Dry run mode

$ modgit add -n scheduler https://github.com/fbrnc/Aoe_Scheduler.git
  => show what would be done

Include filter

$ modgit add -i lib/ elastica git://github.com/ruflin/Elastica.git
  => will deploy only lib/ folder

Include filter with custom target

$ modgit -i lib/:library/ add elastica git://github.com/ruflin/Elastica.git
  => will deploy only lib/ (remote folder) to library/ (local folder)

Exclude filter

$ modgit add -e tests/ atoum https://github.com/atoum/atoum.git
  => will deploy all remote files and folders, except tests/ folder

Automatic modman compatibility

$ modgit add debug https://github.com/madalinoprea/magneto-debug.git
  => will parse remote modman file for files and folders mapping

modgit's People

Contributors

jreinke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modgit's Issues

Nested directories not copied correctly when the source in modman ends in a glob

When a module has a modman file with a glob source pattern (such as one/*), the directory structure inside is not copied to the target correctly.

Please refer to this demo project I've setup: https://github.com/thizzle/modgit-copyissue-demo
The modman file in that module has a single line:
one/* one/

I would expect the file one/two/file.txt to be copied to one/two/file.txt in my project after cloning this module with modgit.
Instead, the directory structure inside the one directory is flattened so that the file is copied to one/file.txt.

Tharsan

submodules

When using modgit on a Magento installation that's SCM'd by git any existing submodules break.

e.g.

$ cd /path/to/project/
$ modgit init
$ modgit clone module-name git://repo.git
$ git submodule init
No submodule mapping found in .gitmodules for path '.modgit/module-name/source'

One solution is to add .modgit to your gitignore, this means that it won't be tracked. I think this is mostly okay as any module updates will be tracked in the magento working directory. However this does limit portability.

Another solution is not to use submodule, making the problem moot, but that's not always practical.

modman filters with chars following a '*' aren't parsed properly in move_files()

If a module contains a modman file containing filters like "*{something}", files that match that filter are not deployed in move_files().

The problem happens when the modman file’s filter expression ends with “{something}”, like “app/etc/modules/.xml”.

Line 337 of modgit is:

line=”${line/*/}” # remove * char

Which means the comparison on line 339 of:

if [[ "$file" =~ ^$1 ]]

will fail in these cases as it will evaluate to something like:

if [[ "app/etc/local.xml.phpunit" =~ "app/etc/modules/.xml" ]]

modgit update

try update a module and this error message

modgit update module_category

Already up-to-date.
You need to run this command from the toplevel of the working tree.
/usr/local/bin/modgit: line 280: [: -eq: unary operator expected
Error updating module_category, operation cancelled.

Files/Directories end in ?

I installed modgit and then attempted to install a couple modules. Checking the backend, nothing is there. Looking at /app/etc/modules I see the module file listed at My_Module.xml?. Also, checking some of the paths under /app/community/ some of the directories also append a ? on the end of the name.

Is this a known issue? I'm on a pretty standard Ubuntu/Trusty64 box.

modman file globbing incompatibility

modgit currently doesn't handle the globbing supported in modman files.

e.g. https://github.com/rjocoleman/Magento-Cloud-Backup/blob/master/modman
Strange things happen around subfolders, see backup.php (a folder) and backup.php.php (the original file).

Cloning into an empty folder using default syntax:

$ mkdir test && cd test
$ modgit init
Initialized Module Git at /Users/robert/Code/test
$ modgit clone cloud-backup git://github.com/rjocoleman/Magento-Cloud-Backup.git
Cloning into '/Users/robert/Code/test/.modgit/cloud-backup/source'...
remote: Counting objects: 101, done.
remote: Compressing objects: 100% (52/52), done.
remote: Total 101 (delta 36), reused 99 (delta 34)
Receiving objects: 100% (101/101), 52.35 KiB, done.
Resolving deltas: 100% (36/36), done.
Clone of cloud-backup complete.

$ tree
.
├── app
│   ├── code
│   │   └── community
│   │       └── Aschroder
│   │           └── CloudBackup
│   │               ├── Helper
│   │               ├── README
│   │               ├── ShakeDown.php
│   │               ├── Test.php
│   │               ├── controllers
│   │               └── email
│   │                   ├── failed_email.html
│   │                   └── success_email.html
│   └── etc
│       └── modules
├── Block
│   ├── Backup.php
│   │   ├── Bucket
│   │   │   └── Grid.php
│   │   ├── Bucket.php
│   │   └── Grid.php
│   └── Backup.php.php
├── Model
│   └── Collection.php
├── etc
│   └── system.xml
└── lib
    └── DevPay.php
        ├── Archive
        │   └── Tar.php
        └── docs
            └── Archive_Tar.txt

16 directories, 16 files

Expected output in tree format, as per modman:

$ tree
.
└── app
    ├── code
    │   └── community
    │       └── Aschroder
    │           └── CloudBackup
    │               ├── Block
    │               │   ├── Backup
    │               │   │   ├── Bucket
    │               │   │   │   └── Grid.php
    │               │   │   ├── Bucket.php
    │               │   │   └── Grid.php
    │               │   └── Backup.php
    │               ├── Helper
    │               │   └── Data.php
    │               ├── Model
    │               │   ├── Backup.php
    │               │   ├── Collection.php
    │               │   └── Form
    │               │       └── Activation.php
    │               ├── README
    │               ├── ShakeDown.php
    │               ├── Test.php
    │               ├── controllers
    │               │   └── BackupController.php
    │               ├── email
    │               │   └── cloudbackup
    │               │       ├── failed_email.html
    │               │       └── success_email.html
    │               ├── etc
    │               │   ├── config.xml
    │               │   └── system.xml
    │               ├── lib
    │               │   ├── Archive_Tar-1.3.7
    │               │   │   ├── Archive
    │               │   │   │   └── Tar.php
    │               │   │   └── docs
    │               │   │       └── Archive_Tar.txt
    │               │   ├── DevPay.php
    │               │   └── S3.php
    │               └── modules
    │                   └── Aschroder_CloudBackup.xml
    └── etc
        └── modules
            └── Aschroder_CloudBackup.xml

22 directories, 22 files

thanks@!

I was reading a magento book when I found this

Sounds simple - and even more simple than modman -

Is this code still maintained? (before we make the change to this method)

modgit rm deleting changed files

modgit removes a changed file instead of reverting the changes on it. Is that an expected behavior?

Example:

Rafaels-MacBook-Pro:main kassner$ ls -la
total 8
drwxr-xr-x   4 kassner  wheel  136 Sep 27 12:39 .
drwxr-xr-x   4 kassner  wheel  136 Sep 27 12:39 ..
drwxr-xr-x  13 kassner  wheel  442 Sep 27 12:39 .git
-rw-r--r--   1 kassner  wheel    4 Sep 27 12:39 test
Rafaels-MacBook-Pro:main kassner$ modgit init
Initialized modgit at /tmp/modgit/main/.modgit/
Rafaels-MacBook-Pro:main kassner$ modgit add mod /tmp/modgit/mod/
Cloning /tmp/modgit/mod/...
Fetching submodules...
Deploying:
test
Installation complete
Rafaels-MacBook-Pro:main kassner$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   test
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .modgit/
no changes added to commit (use "git add" and/or "git commit -a")
Rafaels-MacBook-Pro:main kassner$ git diff test 
diff --git a/test b/test
index 8baef1b..24c5735 100644
--- a/test
+++ b/test
@@ -1 +1 @@
-abc
+def
Rafaels-MacBook-Pro:main kassner$ modgit rm mod
Are you sure you want to remove 'mod' module? (y/n): y
Removing 'mod' module...
Removing files:
test
Rafaels-MacBook-Pro:main kassner$ ls -la
total 0
drwxr-xr-x   4 kassner  wheel  136 Sep 27 12:40 .
drwxr-xr-x   4 kassner  wheel  136 Sep 27 12:39 ..
drwxr-xr-x  13 kassner  wheel  442 Sep 27 12:40 .git
drwxr-xr-x   2 kassner  wheel   68 Sep 27 12:40 .modgit
Rafaels-MacBook-Pro:main kassner$ 

Multi-Store issue

This seems to work with a single website but not with multi-websites.

website1.com -> website1.com/website1/
website2.com -> website2.com/website2/

With your module everything redirects to website1.com

it should be

website1.com -> website1.com
website2.com -> website2.com

Git subtree and modgit

Building on #1.

For context here's my desired workflow:

  1. Set up a repo for a magento store. Seperate repos for modules (third party or own doesn't matter)
  2. Use modgit to install and update modules, adding them magento repo as feature branches etc
  3. Switch branches to work on other functionality/modules etc.
  4. Switch back; merge, push => deploy etc.

To do this I do not ignore .modgit/, I want it to be portable between team members.
Currently I'm seeing untracked files when switching between branches, specifically .modgit/module/source. I think this is due to the .git folder up the tree.

I had breifly flirted with submodules for this task, but in addition to #1 they bring with them a lot of pain in other areas.

git subtree looks like it'd be ideal for this task.
I've hacked together a working git subtree implimentation of modgit over at https://github.com/rjocoleman/modgit/tree/subtree
Please note, it's not battle tested - a prototype at best. Several things are broken such as modgit update-all.
However switching branches etc does perform as I'd expect (i.e. no untracked files)
modgit clone and modgit update have been implimented (albeit with a slightly changed syntax for update).

I'm going to continue testing and refining this as I go, I'm keen to hear feedback on this direction. With subtree living in the git's contrib folder I don't see this as being much more than a runtime option at this point.

remove-all with force option

it would be ideal to be able to do modgit -f remove-all would be useful. I'm thinking about adding it in the fork I have. Would this be something that would be considered?

Also a -q for quite would be good too but -f is needed for a projects I'm working on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.