aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2017-10-22 22:29:52 +0200
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2017-10-22 22:29:52 +0200
commit5d4c2d472e9a2ccdc6866e84aff1ed0a3415f0d6 (patch)
treec8dbbcc6a69409903d60b62583e1f9b34ff7c6cf
parenta764062c62b9ea1a88ec1c8be07d7a768d222249 (diff)
use tempfile instead of own random number
-rw-r--r--vcs_git.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/vcs_git.rb b/vcs_git.rb
index 48a6e29..ffdb983 100644
--- a/vcs_git.rb
+++ b/vcs_git.rb
@@ -21,6 +21,7 @@
require "time"
require_relative "log"
require "open3"
+require 'tempfile'
def runcmd *args
Open3.popen3(*args) {|i,o,e,t| o.read }
@@ -61,15 +62,14 @@ class VCS
end
def VCS.commit comment
- tmpfile = "/tmp/commitcomment.#{rand(10000)}"
- File.open(tmpfile,"w"){|f|
- f<<comment
- }
- ret = runcmd(GITCMD, "commit", "-a", "-F", tmpfile)
- File.delete(tmpfile)
+ tmpfile = Tempfile.new("commit")
+ tmpfile.write(comment)
+ tmpfile.close
+ ret = runcmd(GITCMD, "commit", "-a", "-F", tmpfile.path)
+ tmpfile.unlink
ret
end
-
+
def VCS.branch source, target
runcmd(GITCMD, "clone", source, target)
end