Git Product home page Git Product logo

git-subsplit's Introduction

Git Subsplit

Automate and simplify the process of managing one-way read-only subtree splits.

Git subsplit relies on subtree being available. If is not available in your version of git (likely true for versions older than 1.7.11) please install it manually from here.

Install

git-subsplit can be installed and run standalone by executing git-subsplit.sh directly.

git-subsplit can also be installed as a git command by:

./install.sh

Caveats

There is a known bug in the underlying git-subtree command that this script uses. Your disk will eventually run out of inodes because a cache directory isn't cleaned up after every run. I suggest you to create a cronjob to clean the cache directory every month:

0	0	1	*	*	 rm -rf <path to>/dflydev-git-subsplit-github-webhook/temp/$projectname/.subsplit/.git/subtree-cache/*

Hooks

GitHub WebHooks

Usage

Initialize

Initialize subsplit with a git repository url:

git subsplit init https://github.com/react-php/react

This will create a working directory for the subsplit. It will contain a clone of the project's upstream repository.

Update

Update the subsplit repository with current state of its upstream repository:

git subsplit update

This command should be called before one or more publish commands are called to ensure that the repository in the working directory has been updated from its upstream repository.

Publish

Publish to each subtree split to its own repository:

git subsplit publish \
    src/React/EventLoop:[email protected]:react-php/event-loop.git \
    --heads=master

The pattern for the splits is ${subPath}:${url}. Publish can receive its splits argument as a space separated list:

git subsplit publish "
    src/React/EventLoop:[email protected]:react-php/event-loop.git
    src/React/Stream/:[email protected]:react-php/stream.git
    src/React/Socket/:[email protected]:react-php/socket.git
    src/React/Http/:[email protected]:react-php/http.git
    src/React/Espresso/:[email protected]:react-php/espresso.git
" --heads=master

This command will create subtree splits of the project's repository branches and tags. It will then push each branch and tag to the repository dedicated to the subtree.

--update

Passing --update to the publish command is a shortcut for calling the update command directly.

--heads=<heads>

To specify a list of heads (instead of letting git-subsplit discover them from the upstream repository) you can specify them directly. For example:

--heads="master 2.0"

The above will only sync the master and 2.0 branches, no matter which branches the upstream repository knows about.

--no-heads

Do not sync any heads.

--tags=<tags>

To specify a list of tags (instead of letting git-subsplit discover them from the upstream repository) you can specify them directly. For example:

--tags="v1.0.0 v1.0.3"

The above will only sync the v1.0.0 and v1.0.3 tags, no matter which tags the upstream repository knows about.

--no-tags

Do not sync any tags.

--rebuild-tags

Ordinarily tags will not be synced more than once. This is because in general tags should be considered more or less static.

If for some reason tags need to be resynced from scratch (history changed so tags might point to somewhere else) this flag will get the job done.

-q,--quiet

As little output as possible.

-n,--dry-run

Does not actually publish information to the subsplit repos for each subtree split. Instead, display the command and execute the command with --dry-run included.

--debug

Allows you to see the logic behind the scenes.

Not Invented Here

Inspiration for writing this came from Guzzle's goal of providing components as individually managed packages. Having seen this already done by Symfony and liking how it behaved I wanted to try and see if I could solve this problem in a general case so more people could take advantage of this workflow.

Much time was spent checking out git-subtree and scripts written for managing React's components.

License

MIT, see LICENSE.

Community

If you have questions or want to help out, join us in the #dflydev channel on irc.freenode.net.

git-subsplit's People

Contributors

naderman avatar simensen avatar skyzyx avatar spamoom avatar wellingguzman 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

git-subsplit's Issues

Should be able to use an actual annotated tag for splitted repositories

Currently we simply push the most recent hash to refs/tags/${originalTag} but this may look weird and may be unexpected. We should be able to optionally create an annotated tag that can be pushed up instead. This would probably entail being able to specify a message template ( "Version %tag%", "Tagging %tag%" ) that can result in replacing %tag% with the tag in question.

--tag-message-template="Version %tag%"

... would result in something similar to the following for the tag "v1.0.0":

git tag -a -m "Version v1.0.0" 

skipping head 'develop' (does not exist)

Thanks for this script, it's exactly what I need.

Currently I'm toying around with the subsplit webhook and when I'm trying to init/update and publish any other branch than master, like develop, I'm getting skipping head 'develop' (does not exist)

the git show-ref will not show 'refs/heads/develop' until the branch is checked out in local.

I have switched the refs/heads/${HEAD} to refs/remotes/origin/${HEAD} for the moment and it seems to work now, but I'm wondering if it's the correct way to do this?

Getting a -n in the commit messages

I am getting a -n in front of my commit messages. I am on 10.9 using the built in git with Xcode. Here is an example of a commit message in a message...

commit 290493e555771e015597fa736dc9295b6fbef663
Author: User Name <[email protected]>
Date:   Fri Nov 29 20:28:05 2013 -0500

    -n
    Inital config file to use like the app.php

And here is the original commit message...

commit 7b820bdab1f4178edd410ec96ea43a4191b7ccff
Author: User Name <[email protected]>
Date:   Fri Nov 29 20:28:05 2013 -0500

    Inital config file to use like the app.php

I am running the script as follows...

git subsplit init [email protected]:acme/framework.git
git subsplit publish src/Framework/Base:[email protected]:acme/base.git
git subsplit publish src/Framework/First:[email protected]:acme/first.git
rm -rf .subsplit/

Do not fail silently

Hello

Thanks for this great tool ;)

Is there a reason not to return exit code ?

I'm currently using as standalone script in CI runner, and I cannot get information whether subsplit stage is successful or not.
Would you consider adding an exit code or at least don't redirect stderr so subsplit error can be detected programmaticaly ? Or maybe, there's another way I'm not aware of yet ?

Thanks

Missing tags can be split

It would appear that requesting --tags=MISSING_TAG will still do a healthy chunk of the work even if MISSING_TAG does not exist. This should not be the case.

Tags should not be regenerated by default

Tags should not ordinarily be regenerated as they should be somewhat static. New tags should be created. This can be detected by the existence of the tag branch in the subsplit directory.

All tags will need to be synced in a fresh subsplit. Not sure there is a way around this.

All tags should be able to be force synced from the command line. For example --rebuild-tags or somesuch.

subsplit update does not work on repositories without a master branch

Although developing in a master is a common practice among many projects, such a branch is not required to exist. the subsplit update command, however, hardcodes such a branch and fails if it doesn't exist.

I see three options to solve this problem:

  1. Remove the checking out and resetting of the master branch. I'm not really sure what purpose it serves in the first place, but I'm probably missing something.
  2. Make the branch to check out and reset configurable with a --branchoption (or similar).
  3. Automatically figure out the branch to check out and reset by some arcane magic.

I'd love to hear your thoughts on this. Thanks!

inode leak

Hi,

I think subsplit has some kind of inode-leak:

root::gitlab { .../KunstmaanBundlesCMS/.subsplit/.git }-> pwd
/home/subsplit/dflydev-git-subsplit-github-webhook/temp/KunstmaanBundlesCMS/.subsplit/.git
root::gitlab { .../KunstmaanBundlesCMS/.subsplit/.git }-> for i in *; do echo -e "$(find $i | wc -l)\t$i"; done | sort -n
1   branches
1   config
1   description
1   FETCH_HEAD
1   HEAD
1   index
1   ORIG_HEAD
1   packed-refs
3   info
6   objects
10  hooks
75  refs
319 logs
7275935 subtree-cache

Is this a bug or am I supposed to rm the subtree-cache directory on a regular basis? Our server has run out of inodes twice.

Thx

Do not silence failure form subtree command

@igorw had an issue that would have been more easily detected if errors form subtree were not silenced.

The reasons for the silence to begin with was because prefixes may legitimately not exist in all branches and the output would have been somewhat confusing/meaningless:

'src/MyProject/Missing' does not exist; use 'git subtree add'

Suggestion was to try and catch the error and do something different depending on the response. For example, search output for "git subtree add" and if it exists, ignore it, otherwise, fail and show it (or at least warn somehow).

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.