Code Monkey home page Code Monkey logo

git-oneflow's Introduction

git-OneFlow

CodeFactor npm code style: prettier Conventional Commits Dependabot Status CodeQL

CLI tools implementing the OneFlow git branching model.

OneFlow is a git branching model proposed by Adam Ruka as an alternative to GitFlow.

In this article, Adam describes how it works and when it should be employed.

This workflow is not for the uninitiated:

  1. Heavy use of rebase
  2. By default, work is off of main
  3. ???
  4. No Profit :( and surefire way to mess things up quickly and embarrassingly.

For a good overview of why you should and when you shouldn't use rebase read this

I have simply put together some CLI commands to leverage the OneFlow model.

I have remained strictly faithful to how Adam defines the workflow without adding anything fancy (yet). This means that, by default, git-OneFlow works with one main branch only (main) and new features are rebased. Check the customisation section.

Of course, one-size-fits-all does not always work, therefore, I have implemented all the feature integration options described in the article and both the one main branch and main and development branches models.

Fun facts:

  1. Two branches model + integration option #2 gives... :drumroll: GitFlow :)
  2. Adam Ruka doesn't really like the idea of 'tools' like this one

Node Compatibility

Supported version are LTS and above.

Install

npm install -g git-oneflow

Usage

git-oneflow --help

or

gof --help

gof is a convenient alias for the overly verbose and long to type git-oneflow.

Node Package Execute - npx

It is possible to run git-oneflow directly (i.e. no local installation) from the npm registry with Node Package Execute:

npx git-oneflow --help

Configuration

git-OneFlow comes with some defaults which faithfully mirror Adam Ruka recommendations.

Defaults

One main branch

main

Feature branches

Feature branches stem from feature:

gof start feature my-feature
# equivalent to...
git checkout -b feature/my-feature

Finishing a feature is done by rebasing:

gof finish feature my-feature
# equivalent to...
git checkout feature/my-feature
git rebase -i main
git checkout main
git merge --ff-only feature/my-feature
git push origin main
git branch -d feature/my-feature

Release/Hotfix branches

Releases and hotfixes share the same workflow: (just substitute hotfix for release in the following examples)

gof start release 2.3.0
# equivalent to...
git checkout -b release/2.3.0

...then

gof finish release 2.3.0 -t 2.3.0
# equivalent to...
git checkout release/2.3.0
git tag -a -m '2.3.0' 2.3.0
git checkout main
git merge release/2.3.0
git push --follow-tags origin main
git branch -d release/2.3.0
Tags

Tags creation when releasing or hot-fixing might not be needed. One case would be if something like standard-version is used, which tags releases based on some commit conventions. Therefore, a --no-tag option is used to avoid tagging the commit. A commit is either tagged on the command line by passing -t|--tag <tagName> or the program will ask to specify a tag name. If both -t and --no-tag are specified, --no-tag takes the precedence. This is true for any other off switch.

Configuration file

gof init

init starts an interactive session that allows for customising the configuration of git-OneFlow

This creates a .git-oneflowrc file with the chosen configuration options. git-OneFlow uses cosmiconfig under the hood.

To specify a configuration file on the command line use -c|--configuration with the name of the file (and it's path).

gof start feature -c config/my-gof-config.json

Configuration options

Option Description Default Details
main name of the main (production) branch main must be set to an existing branch name
development name of the development branch undefined not set or an existing branch name
features name of the features branch (prefixed to the feature name) feature empty string or a valid branch name. This strings works as a branch prefix, e.g. if the chosen feature name is my-super-feature the resulting (using the default) branch name for this feature will be feature/my-super-feature. An empty string will result in my-super-feature. This applies to releases and hotfixes as well.
releases name of the releases branch (prefixed to the release name) release empty string or a valid branch name
hotfixes name of the hotfixes branch (prefixed to the hotfix name) hotfix empty string or a valid branch name
strategy which feature integration merge strategy to use rebase Valid options are: rebase, rebase-no-ff and no-ff
interactive whether to rebase interactively rebase -i true the values true or false, not the strings 'true' or 'false'. See example. If set to false this, and other boolean options, act as a permanent off switch for the given option. In this case, it is like --no-interactive is always specified on the command line.
pushAfterMerge whether to push to origin after finishing true true, false
deleteAfterMerge whether to delete the working branch after merging with main/development true true, false
tagCommit whether to ask to tag releases and hotfixes true true, false. This option is used to decide whether to prompt the user or not in case a tag hasn't been specified, for example with --tag 2.3.4.
askOnFeatureStart whether to ask which branch to start a feature from false true, false. This option is used to decide whether to prompt the user or not in case they start a feature.
askOnFeatureFinish whether to ask which branch to merge a feature onto false true, false. This option is used to decide whether to prompt the user or not in case they finish a feature.

Generate default file

To create a configuration file with default values:

gof init -y

this will create .gitonelfowrc in the current directory with the following content:

{
  "main": "main",
  "features": "feature",
  "releases": "release",
  "hotfixes": "hotfix",
  "strategy": "rebase",
  "interactive": true,
  "deleteAfterMerge": true,
  "pushAfterMerge": true,
  "tagCommit": true
}

Commands

Under the hood, git-OneFlow uses commander. Essentially, it is possible to start or finish either a feature, a release or an hotfix.

Each command can be passed options that modify the default behaviour.

Common options to all commands

Option flag Description
-c, --config <file> configuration file to use
-b, --base <name> override the current base branch name
--no-base do not use a base branch name

The start command

gof start <feature|release|hotfix> [options] [name]

Commands can be shortened using the initial letter:

gof s f -h # => gof start feature --help

start options

Options are common to every sub-command (start feature, start release, start hotfix)

Option flag Description
-r, --ref <ref> new branch will be created from the given branch, commit or tag
--no-ref create the new branch from the current branch

The finish command

The finish command syntax is exactly the same as the start command. What changes are the options that can be passed to the sub-commands.

Common finish options

Option flag Description
-o,--onto <onto> branch to merge or rebase onto
-p,--push push to origin after merge
--no-push do not push
-d,--delete delete branch after merge
--no-delete do not delete branch

finish feature options

Option flag Description
-i,--interactive interactive rebase
--no-interactive do not rebase interactively
-s,--strategy <strategy> merge strategy

finish release and finish hotfix options

Option flag Description
-t,--tag <tagName> tag the commit with the given tag
--no-tag do not tag the commit
-m,--message <msg> annotate tag with a message (default to the tag name)

--help and --dry-run options

A help menu is available with every command. Just append -h or --help to access help.

gof finish release --help

Another interesting way to experiment with git-OneFlow is to use the --dry-run option. This will show the commands that would be invoked without actually doing anything.

It is possible to activate the dry-run mode also by setting the environment variable GOF_DRY_RUN

GOF_DRY_RUN=1 gof start release

or for Windows

set GOF_DRY_RUN=1 & gof start release

Changelog

The changelog can be found on the Releases page.

Contributing

PRs welcome!

License

git-OneFlow is released under the MIT License. See LICENSE for more details.

git-oneflow's People

Contributors

codacy-badger avatar dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar greenkeeper[bot] avatar kodiakhq[bot] avatar msanguineti avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

git-oneflow's Issues

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.29.1 to 1.30.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v1.30.0

2020-01-27

Features

  • Do not split chunks when dynamically imported modules import modules that are already loaded by all dynamic importers (#3354)
  • Add hoistTransitiveImports option to disable hoisting imports of static dependencies into entry chunks (#3353)

Bug Fixes

  • Make sure polyfills are always loaded first when each static entry point contains them as first import (#3354)

Pull Requests

Commits

The new version differs by 4 commits.

  • 91aa1a7 1.30.0
  • 372fe0d Update changelog
  • 075933a Add option to avoid hoisting transitive imports (#3353)
  • 7fc24ab Improve chunking algorithm for dynamic imports (#3354)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of yargs is breaking the build 🚨

The dependency yargs was updated from 13.2.4 to 13.3.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

yargs is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v13.3.0

Bug Fixes

  • deps: yargs-parser update addressing several parsing bugs (#1357) (e230d5b)

Features

  • i18n: swap out os-locale dependency for simple inline implementation (#1356) (4dfa19b)
  • support defaultDescription for positional arguments (812048c)
Commits

The new version differs by 4 commits.

  • 59739e6 chore: release 13.3.0 (#1358)
  • e230d5b fix(deps): yargs-parser update addressing several parsing bugs (#1357)
  • 4dfa19b feat(i18n): swap out os-locale dependency for simple inline implementation (#1356)
  • 812048c feat: support defaultDescription for positional arguments

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/inquirer is breaking the build 🚨

The devDependency @types/inquirer was updated from 6.0.3 to 6.5.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/inquirer is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.27.6 to 1.27.7.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v1.27.7

2019-12-01

Bug Fixes

  • Fix a scenario where a reassignments to computed properties were not tracked (#3267)

Pull Requests

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Update merge options

Hello Mirco. First, congratulations on making this tool, it really helps to comprehend and start with OneFlow. I just recently read the newer article Adam created on OneFlow, and I'd like to use your tool, except on the configs, I saw there's no option to merge using --squash, the method Adam recommend's the most. Would it be too much trouble to have this in your project?

I thank you kindly,
Jose Ferreira

An in-range update of commitlint is breaking the build 🚨

There have been updates to the commitlint monorepo:

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the commitlint group definition.

commitlint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 39 commits.

  • c17420d v8.1.0
  • ca19d70 chore: update dependency lodash to v4.17.14 (#724)
  • 5757ef2 build(deps): bump lodash.template from 4.4.0 to 4.5.0 (#721)
  • 5b5f855 build(deps): bump lodash.merge from 4.6.0 to 4.6.2 (#722)
  • 4cb979d build(deps): bump lodash from 4.17.11 to 4.17.13 (#723)
  • a89c1ba chore: add devcontainer setup
  • 9aa5709 chore: pin dependencies (#714)
  • c9ef5e2 chore: centralize typescript and jest setups (#710)
  • c9dcf1a chore: pin dependencies (#708)
  • 6a6a8b0 refactor: rewrite top level to typescript (#679)
  • 0fedbc0 chore: update dependency @types/jest to v24.0.15 (#694)
  • 0b9c7ed chore: update dependency typescript to v3.5.2 (#695)
  • 4efb34b chore: update dependency globby to v10 (#705)
  • 804af8b chore: update dependency lint-staged to v8.2.1 (#696)
  • 9075844 fix: add explicit dependency on chalk (#687)

There are 39 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.18.0 to 1.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 6 commits.

  • 9af119d 1.19.0
  • b3f361c Update changelog
  • 456f4d2 Avoid variable from empty module name be empty (#3026)
  • 17eaa43 Use id of last module in chunk as name base for auto-generated chunks (#3025)
  • 871bfa0 Switch to a code-splitting build and update dependencies (#3020)
  • 2443783 Unified file emission api (#2999)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

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.