version_control.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. checkout_eval_branch() {
  2. if [ -z "$COMMIT_HASH" ]; then
  3. echo "Commit hash not specified, use current git commit"
  4. return 0
  5. fi
  6. echo "Start to checkout opendevin version to $COMMIT_HASH, but keep current evaluation harness"
  7. if ! git diff-index --quiet HEAD --; then
  8. echo "There are uncommitted changes, please stash or commit them first"
  9. exit 1
  10. fi
  11. current_branch=$(git rev-parse --abbrev-ref HEAD)
  12. echo "Current version is: $current_branch"
  13. echo "Check out OpenDevin to version: $COMMIT_HASH"
  14. if ! git checkout $COMMIT_HASH; then
  15. echo "Failed to check out to $COMMIT_HASH"
  16. exit 1
  17. fi
  18. echo "Revert changes in evaluation folder"
  19. git checkout $current_branch -- evaluation
  20. }
  21. checkout_original_branch() {
  22. if [ -z "$current_branch" ]; then
  23. return 0
  24. fi
  25. echo "Checkout back to original branch $current_branch"
  26. git checkout $current_branch
  27. }
  28. get_agent_version() {
  29. # IMPORTANT: Because Agent's prompt changes fairly often in the rapidly evolving codebase of OpenDevin
  30. # We need to track the version of Agent in the evaluation to make sure results are comparable
  31. AGENT_VERSION=v$(poetry run python -c "import agenthub; from opendevin.controller.agent import Agent; print(Agent.get_cls('$AGENT').VERSION)")
  32. }