Giter VIP home page Giter VIP logo

git-test's Introduction

git-test

Simple CLI utility to test git output and return exit 1 if a test fails

Installation

npm install -g git-test-cli

Usage

[master] > git-test -b master && echo on master || echo not on master
on master

[master] > git checkout feature
[feature] > git-test -b master && echo on master || echo not on master
not on master

The intended use is as a scripting helper, e.g. to perform certain actions during automated processes (such as builds) based on the current git branch. For example, using husky, the following will run tests before pushing code to master:

{
   "scripts": {
       "prepush": "git-test -b master && npm test || git-test -x -b master"
   } 
}

The -x option inverts the result of the test, e.g. tests that the branch is not master. The negative test following the || is needed to ensure the logic following the initial test is atomic. That is, every logical test that starts with the assertion "if I'm on this branch" should end with an "or" condition of "if I'm not on this branch".

Right now it's only feature is to test which branch is active. If I need more... I will add it.

Options

--branch [branch-name]
-b [branch-name]

Test that the current git repo is on [branch-name]

--except [branch-name]
-x [branch-name]

Invert the result of every other test

--help

Show help

--status

Just output the status info I obtained from git as JSON (for diagnostics)

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.