Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. basic ruby script not working as expected
  2. def performCommandInDir(command, dir)
  3.   old_dir = Dir.pwd
  4.   Dir.chdir(dir)
  5.   system(command)
  6.   Dir.chdir(old_dir)
  7. end
  8.        
  9. performCommandInDir("git svn rebase", repo[:name])
  10.        
  11. fatal: /usr/libexec/git-core/git-rebase cannot be used without a working tree.
  12. rebase refs/remotes/git-svn: command returned error: 1
  13.        
  14. system("git --git-dir=#{repo[:name]}/.git --work-tree=#{repo[:name]} svn rebase")
  15.        
  16. def performCommandInDir(command, dir)
  17.   system(command, :chdir => dir)
  18. end
  19.        
  20. Dir.chdir(dir) do
  21.   # your actions
  22. end
  23. # back in the original directory
  24.        
  25. def performCommandInDir(command, dir)
  26.     system("cd #{dir} && #{command}")
  27. end