diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2017-10-22 22:29:52 +0200 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2017-10-22 22:29:52 +0200 |
commit | 5d4c2d472e9a2ccdc6866e84aff1ed0a3415f0d6 (patch) | |
tree | c8dbbcc6a69409903d60b62583e1f9b34ff7c6cf | |
parent | a764062c62b9ea1a88ec1c8be07d7a768d222249 (diff) |
use tempfile instead of own random number
-rw-r--r-- | vcs_git.rb | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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 |