#!/usr/bin/env bats @test "soloing" { git-together with jh touch foo git add foo git-together commit -m "add foo" run git show --no-patch --format="%aN <%aE>" [ "$output" = "James Holden " ] run git show --no-patch --format=%B [[ ! "$output" =~ "Signed-off-by:" ]] } @test "pairing" { git-together with jh nn touch foo git add foo git-together commit -m "add foo" run git show --no-patch --format="%aN <%aE>" [ "$output" = "James Holden " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: Naomi Nagata " ]] } @test "rotation" { git-together with jh nn touch foo git add foo git-together commit -m "add foo" touch bar git add bar git-together commit -m "add bar" run git show --no-patch --format="%aN <%aE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "James Holden " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: James Holden " ]] } @test "mobbing" { git-together with jh nn ca touch foo git add foo git-together commit -m "add foo" run git show --no-patch --format="%aN <%aE>" [ "$output" = "James Holden " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: Naomi Nagata " ]] touch bar git add bar git-together commit -m "add bar" run git show --no-patch --format="%aN <%aE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "Chrisjen Avasarala " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: Chrisjen Avasarala " ]] touch baz git add baz git-together commit -m "add baz" run git show --no-patch --format="%aN <%aE>" [ "$output" = "Chrisjen Avasarala " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "James Holden " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: James Holden " ]] } @test "auto-including .git-together" { git-together with jh run git config --local include.path [ "$status" -eq 1 ] touch .git-together git-together with jh run git config --local include.path [ "$output" = "../.git-together" ] git-together with jh run git config --local --get-all include.path [ "$output" = "../.git-together" ] } @test "list current authors" { git-together with jh nn run git-together with expected=$(cat < nn: Naomi Nagata AUTHORS ) [[ "$output" =~ "$expected" ]] run git config git-together.active [ "$output" = "jh+nn" ] } @test "list all authors" { git-together with jh run git-together with --list expected=$(cat < jh: James Holden nn: Naomi Nagata AUTHORS ) [[ "$output" =~ "$expected" ]] run git config git-together.active [ "$output" = "jh" ] } @test "no signoff" { git-together with jh nn touch foo git add foo GIT_TOGETHER_NO_SIGNOFF=1 git-together commit -m "add foo" run git show --no-patch --format="%aN <%aE>" [ "$output" = "James Holden " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format=%B [[ ! "$output" =~ "Signed-off-by: Naomi Nagata " ]] } @test "merging" { git-together with jh nn touch foo git add foo git-together commit -m "add foo" git checkout -b bar touch bar git add bar git-together commit -m "add bar" git checkout - git-together merge --no-edit --no-ff bar run git show --no-patch --format="%aN <%aE>" [ "$output" = "James Holden " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format=%B [[ ! "$output" =~ "Signed-off-by:" ]] } @test "reverting" { git-together with jh nn touch foo git add foo git-together commit -m "add foo" git-together revert --no-edit HEAD run git show --no-patch --format="%aN <%aE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "James Holden " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: James Holden " ]] } @test "not in a git repo" { cd $BATS_TMPDIR run git-together with --list [ "$status" -eq 0 ] } @test "clear" { git-together with jh git-together with --clear run git config git-together.active [ "$output" = "" ] } @test "together" { git-together together jh nn touch foo git add foo git-together commit -m "add foo" run git show --no-patch --format="%aN <%aE>" [ "$output" = "James Holden " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: Naomi Nagata " ]] } @test "aliases" { git config --local alias.ci commit git config --local git-together.aliases m,ci,r git-together with jh nn touch foo git add foo git-together ci -m "add foo" run git show --no-patch --format="%aN <%aE>" [ "$output" = "James Holden " ] run git show --no-patch --format="%cN <%cE>" [ "$output" = "Naomi Nagata " ] run git show --no-patch --format=%B [[ "$output" =~ "Signed-off-by: Naomi Nagata " ]] } @test "global args" { git-together with jh nn touch foo git add foo git-together -c commit.verbose=false commit -m "add foo" } setup() { # [ -f $BATS_TMPDIR/bin/git-together ] || cargo install --root $BATS_TMPDIR rm -rf $BATS_TMPDIR/bin cargo install --path . --root $BATS_TMPDIR PATH=$BATS_TMPDIR/bin:$PATH rm -rf $BATS_TMPDIR/$BATS_TEST_NAME mkdir -p $BATS_TMPDIR/$BATS_TEST_NAME cd $BATS_TMPDIR/$BATS_TEST_NAME git init git config --add git-together.domain rocinante.com git config --add git-together.authors.jh "James Holden; jholden" git config --add git-together.authors.nn "Naomi Nagata; nnagata" git config --add git-together.authors.ca "Chrisjen Avasarala; avasarala@un.gov" }