push-basic.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2012 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. set -e
  6. . ./test-lib.sh
  7. setup_initgit
  8. setup_gitgit
  9. (
  10. set -e
  11. cd git-git
  12. git checkout -q --track -b work origin
  13. echo "some work done on a branch" >> test
  14. git add test; git commit -q -m "branch work"
  15. echo "some other work done on a branch" >> test
  16. git add test; git commit -q -m "branch work"
  17. test_expect_success "git-cl upload wants a server" \
  18. "$GIT_CL upload 2>&1 | grep -q 'You must configure'"
  19. git config rietveld.server localhost:10000
  20. test_expect_success "git-cl status has no issue" \
  21. "$GIT_CL_STATUS | grep -q 'no issue'"
  22. # Prevent the editor from coming up when you upload.
  23. export GIT_EDITOR=$(which true)
  24. test_expect_success "upload succeeds (needs a server running on localhost)" \
  25. "$GIT_CL upload -m test master | grep -q 'Issue created'"
  26. test_expect_success "git-cl status now knows the issue" \
  27. "$GIT_CL_STATUS | grep -q 'Issue number'"
  28. # Push a description to this URL.
  29. URL=$($GIT_CL_STATUS | sed -ne '/Issue number/s/[^(]*(\(.*\))/\1/p')
  30. curl --cookie dev_appserver_login="test@example.com:False" \
  31. --data-urlencode subject="test" \
  32. --data-urlencode description="foo-quux" \
  33. --data-urlencode xsrf_token="$(print_xsrf_token)" \
  34. $URL/edit
  35. test_expect_success "Base URL contains branch name" \
  36. "curl -s $($GIT_CL_STATUS --field=url) | grep 'URL:[[:space:]]*[^<]' | grep -q '@master'"
  37. test_expect_success "git-cl push ok" \
  38. "$GIT_CL push -f"
  39. git checkout -q master > /dev/null 2>&1
  40. git pull -q > /dev/null 2>&1
  41. test_expect_success "committed code has proper description" \
  42. "git show | grep -q 'foo-quux'"
  43. test_expect_success "issue no longer has a branch" \
  44. "$GIT_CL_STATUS | grep -q 'work : None'"
  45. cd $GITREPO_PATH
  46. test_expect_success "upstream repo has our commit" \
  47. "git log master 2>/dev/null | grep -q 'foo-quux'"
  48. )
  49. SUCCESS=$?
  50. cleanup
  51. if [ $SUCCESS == 0 ]; then
  52. echo PASS
  53. fi