Merge remote-tracking branch 'origin/master' into 2075-workbench-paging
[arvados.git] / services / api / app / models / commit.rb
index af08c1d1a5a0704800c83364735477a9f9d153a4..d7d0571067a70878b0712c169a79be0c3bbc1b35 100644 (file)
@@ -43,11 +43,8 @@ class Commit < ActiveRecord::Base
       IO.foreach("|git rev-list --format=oneline --all") do |line|
         sha1, message = line.strip.split " ", 2
         imported = false
-        begin
-          imported = Commit.new(repository_name: repo_name,
-                                sha1: sha1,
-                                message: message[0..254]).save
-        rescue ActiveRecord::RecordNotUnique
+        Commit.find_or_create_by_repository_name_and_sha1_and_message(repo_name, sha1, message[0..254]) do
+          imported = true
         end
         stat[!!imported] += 1
         if (stat[true] + stat[false]) % 100 == 0