push-from-logs.sh 2.07 KB
Newer Older
1 2
#!/bin/bash

3 4 5 6
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
set -e

. ./test-lib.sh

setup_initgit
setup_gitgit

(
  set -e
  cd git-git
  git checkout -q --track -b work origin
  echo "some work done on a branch" >> test
  git add test; git commit -q -m "branch work"
  echo "some other work done on a branch" >> test
  git add test; git commit -q -m "branch work"

  test_expect_success "git-cl upload wants a server" \
    "$GIT_CL upload 2>&1 | grep -q 'You must configure'"

  git config rietveld.server localhost:8080

  test_expect_success "git-cl status has no issue" \
    "$GIT_CL status | grep -q 'no issue'"

  # Prevent the editor from coming up when you upload.
  export EDITOR=$(which true)
  test_expect_success "upload succeeds (needs a server running on localhost)" \
34
      "$GIT_CL upload -m test master | \
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
      grep -q 'Issue created'"

  test_expect_success "git-cl status now knows the issue" \
      "$GIT_CL status | grep -q 'Issue number'"

  # Check to see if the description contains the local commit messages.
  # Should contain 'branch work' x 2.
  test_expect_success "git-cl status has the right description for the log" \
      "$GIT_CL status --field desc | [ $( egrep -q '^branch work$' -c ) -eq 2 ]
  
  test_expect_success "git-cl status has the right subject from message" \
      "$GIT_CL status --field desc | \
      [ $( egrep -q '^test$' --byte-offset) | grep '^0:' ]

  test_expect_success "git-cl push ok" \
    "$GIT_CL push -f"

  git checkout -q master > /dev/null 2>&1
  git pull -q > /dev/null 2>&1

  test_expect_success "committed code has proper description" \
      "git show | [ $( egrep -q '^branch work$' -c ) -eq 2 ]

  test_expect_success "issue no longer has a branch" \
      "git cl status | grep -q 'work: None'"

  cd $GITREPO_PATH
  test_expect_success "upstream repo has our commit" \
      "git log master 2>/dev/null | [ $( egrep -q '^branch work$' -c ) -eq 2 ]
)
SUCCESS=$?

cleanup

if [ $SUCCESS == 0 ]; then
  echo PASS
fi