Code Monkey home page Code Monkey logo

detoul's Introduction

Detoul

Ramon Snir (c) 2015 [MIT License]

A declarative tool for creating integration branches in git

Why?

I found that during development of a version, people wish to test if their code works with other team members' changes. My team members often had issues with the integration branches, merging the integration branches into their feature branches (and then forcing us to start slowly rebasing the feature branches, to take out commits that were meant for a future version but still needed testing).

How?

(further explanation will come in the future, and of course with new features)

Create your release specification branch:

detoul init
detoul create release-february master

Release specifications are placed in the detoul-spec branch and are named by the file name of the specification file. Let's say we have the following content for the committed release-february file in detoul-spec:

checkout master
take Task-1
take Task-3
take-squash Task-4 add dropdowns support
pick 40abfe3

Then we could test that it can be built without conflicts:

$ detoul test release-february
Checking out 'master'...
Taking 'Task-1-improve-buttons'...
Taking 'Task-2-fix-tables'...
Taking 'Task-3-add-dropdowns' (squashed)...
Picking '40abfe3'...
Integration branch succesfully created.

This means the branch is good, and we can then push our changes to detoul-spec to our remote repository and redeploy the release.

To actually make the branch (to test it or to use it), we can run detoul make release-february.

If your deployment procedured isn't configured to make the latest detoul branch, then you can make it and push it in a single command (detoul push release-february) and then deploy the branch release-february.

Installation

git clone https://github.com/ramonsnir/detoul && cd detoul && ./install.sh

There are some packages available that install detoul. More are planned (if you would like to help create packages - feel free to contribute!).

Requirements

Until detoul has a good test suite, this list should be taken with a grain of salt.

Linux
  • a Linux-compatible operating system with a Bourne shell (bash)
  • the perl5 interpreter
  • git 1.7+ (developed with git 2.2.1, but also tested with a Centos 6.5 machine with git 1.7.1)
Cygwin

A Windows machine with Cygwin bash could use detoul too (note that perl is available as a Cygwin package). The colorized output in Cygwin has less colors (as it supports fewer colors than most terminal emulators), but that shouldn't bother users too much. If it does, then it is probably time for you to find out that Cygwin comes with Mintty (which is a pretty good terminal emulator - much better than the Windows command prompt) and can also work with xterm (which is available as a Cygwin package).

MinGW

Please see the issue #21.

detoul help

detoul: a declarative tool for creating integration branches in git
Usage:
    detoul init
    detoul specs-push
    detoul specs-pull
    detoul create <release> [<base_branch>]
    detoul (test|make) <release>
    detoul add-to <release> <branch> [--squash] [--merge] [--message "<message>"]
    detoul cat (<release>|<archived-release>)
    detoul edit <release> [--amend]
    detoul push <release>
    detoul archive <release>
    detoul unarchive <archived-release>
    detoul help

rebase vs merge

The default take and take-squash actions behave a lot like git-rebase and so will not play nicely with all merge-detection methods (so Github and Bitbucket will not automatically mark relevant pull requests as merged).

If you don't like this behavior, you can instead use take-merge (or detoul add-to <release> <branch> --merge) which will keep the source branch an ancestor of the target branch.

Using git-rerere with detoul

Clearly unless all your feature branches are always completely disjoint, then you will often have merge conflicts between branches. detoul employs git-rerere to reuse recorded resolutions of conflicts. If you try to detoul make a release and detoul encounters a conflict, it will exit with a failure but will allow you to manually resolve the merge conflict. If you configured your git to use git-rerere (by calling git config rerere.enabled true), then it will automatically record your conflict resolution. The next time you run detoul make for the release, detoul will take your recorded resolutions and use them to resolve the encountered conflict. detoul will then save the rr-cache (recorded resolutions cache) inside the detoul-spec branch so that everyone that wishes to build the release could reuse your recorded resolutions automatically.

Note that while your resolutions will not be recorded without enabled git-rerere, detoul will automatically use recorded resolutions even without enabling git-rerere enabled in your local repository (of course, assuming someone recorded the conflict resolution before).

Auto-completion gone wrong

After a couple of dozen releases, the release name auto-completion starts to be less useful, as there are too many irrelevant releases. If it bothers you, you can "archive" old releases using detoul archive. Archived releases won't be suggested by the auto-completion, and will not be built by mistake. They can still be browsed using detoul cat (which will also continue to auto-complete on them), and can be revived at any time using detoul unarchive.

Why in bash?

I wrote this on my own time, and wanted to have fun. It shouldn't take more than an hour to translate detoul into any other language, once I choose to which one.

detoul's People

Contributors

adrianei avatar ramonsnir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pinih yossi-dy

detoul's Issues

support scripts for `run`

New commands to be added:

detoul script-install <file-path> [<name>]
detoul script-uninstall <name>
detoul script-cat <name>
detoul script-edit <name>

Installed scripts will be automatically in the $PATH for run directives (see #37).

create a Windows installer

First, there should be an installer for each release (hopefully it can be automatically built with a simple Makefile). It just has to deploy the code at a good location, add it to the Cygwin path, and make sure that the bash-completion script is sourced every time.

Second, there should be a "latest" installer that keeps the source code up-to-date with the git repository. Other than that, it should behave just the same as the per-release installer.

support "true" merge-takes

Instead of today's rebase-squash-add-parent, actually run git merge (plus all the goodies that take has). This should be a drop-in replacement, but with easier conflicts to resolve.

Not marking as breaking changes, until a scenario that works with the old take-merge is found not to be working with the new take-merge

write Unit Tests for detoul

I see no need for a description.

There should be a command like detoul run-unit-tests that tests that detoul runs all right on the machine (in addition to dependency checking done by the package manager), especially while in Alpha/Beta releases. This will help identify issues and hidden dependencies earlier.

`detoul edit` (if there was a change) takes a long time

I can no longer reproduce it, but I will leave here all the details I've gathered back when it was deterministically reproducible (sadly, on a proprietary closed-source project).

It was last reproduced with detoul from 3c9184d .

When using detoul edit, adding a comment, detoul would commit the change but not close the stdout pipe (stderr pipe closed correctly). This caused the terminal to hang for about 10-20 seconds (because the cat that runs on stdout didn't exit).

If the problem occurs again, it will be known that either (a) it existed since at least 6171f8e or (b) it existed back then, was resolved, and then reintroduced. Even in case (b), this issue could be helpful for diagnosing - as today detoul's source code is pretty short and simple, and if it gets complicated - it might be easier to test the issue on an older revision.

If the problem doesn't occur again, it might still be interesting to find out what was happening.

rename all the take's and rebase's

Suggested scheme:

  • rebase => take
  • rebase-squash => take-squash
  • take-squash => take-merge

And then detoul add-to will behave accordingly:

  • no flags => take (--message ignored)
  • --squash => take-squash
  • --merge => take-merge

create a package for Mac

See #6.

I have no experience with development on Mac, and I don't even know which package managers are common for the White OS.

support MinGW

Today Windows is only supported with Cygwin. This is (somewhat) an issue, because the "Git Bash" utility uses MinGW.

One issue at least that exists:

  • grep doesn't support the -P argument

allow archiving of old spec files

This will both remove them from the auto-complete suggestions, and stop erroneous dependencies on them.

They should be kept in detoul-spec/.archive/specs.

The command should be a trivial detoul archive <release>.

There should be detoul unarchive <archived-release>, and detoul cat should work on both <release> and <archived-release>.

create an Arch package

Most importantly, there should be an Arch package for latest release. There should also be a detoul-git package offering the latest bleeding-edge version.

support a `run` directive

run (which in its basic form is an alias for the now-deprecated exec directive) should run the given command under bash, when building the target release.

run will have two aliases:

  • first-run
  • finally-run
    , which will do exactly the same with a single difference: detoul add-to will insert the take directive before all run-last directives.

A new command, detoul add-script-run-to <release> [--first|--finally] <command> will add a run line to the <release> script, or a first-run or a finally-run if applicable (and of course, place them correctly).

The order of finally-run directives should be maintained to be chronological by all utility command. The order of first-run directives should be maintained to be reverse-chronological by all utility command.

organize the `specs-push` and `specs-pull` commands

Today:

  • specs-push runs git push -f
  • specs-pull runs git pull

They both should be "soft" on default, and both should have a --force flag.
specs-pull should use git pull --ff-only on default, unless given arguments --merge (which removes --ff-only) or --rebase (which replaces the --ff-only with --rebase).

support "computed branches"

They can be done today by creating a fictitious release spec with a series of "exec", but it could be modeled more elegantly, without requiring to update the "checkout" line.

(Explanation:
these are branches that are computed every time from other resources, for example a compilation output of a different project)

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.