Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set promoted_at upon promotion; refuse to update promoted jars.

  • Loading branch information...
commit 2382d5ed4ba71435a37bb8fe261d41f4ba3b3719 1 parent a4287a7
@technomancy authored
Showing with 26 additions and 7 deletions.
  1. +6 −0 src/clojars/db.clj
  2. +20 −7 src/clojars/promote.clj
View
6 src/clojars/db.clj
@@ -196,6 +196,12 @@
(defn update-jar [account {:keys [group name version
description homepage authors]}]
+ (let [[{:keys [promoted_at]}] (select jars (fields :promoted_at)
+ (where {:group_name group
+ :jar_name name
+ :version version}))]
+ (when promoted_at
+ (throw (Exception. "Already promoted."))))
(update jars
(set-fields {:user account
:created (get-time)
View
27 src/clojars/promote.clj
@@ -2,7 +2,9 @@
(:require [clojars.config :refer [config]]
[clojars.maven :as maven]
[clojure.java.io :as io]
- [cemerick.pomegranate.aether :as aether])
+ [cemerick.pomegranate.aether :as aether]
+ [clojars.db :as db]
+ [korma.core :refer [select fields where update set-fields]])
(:import (java.util.concurrent LinkedBlockingQueue)
(org.springframework.aws.maven SimpleStorageServiceWagon)))
@@ -29,15 +31,21 @@
;; TODO: implement
blockers)
-(defn unpromoted? [blockers info]
- ;; TODO: check DB, needs migration
- blockers)
+(defn unpromoted? [blockers {:keys [group name version]}]
+ (let [[{:keys [promoted_at]}] (select db/jars (fields :promoted_at)
+ (where {:group_name group
+ :jar_name name
+ :version version}))]
+ (if promoted_at
+ (conj blockers "Already promoted.")
+ blockers)))
(defn blockers [{:keys [group name version]}]
(let [jar (file-for group name version "jar")
pom (file-for group name version "pom")
info (try (maven/pom-to-map pom)
(catch Exception _ {}))]
+ ;; TODO: convert this to a lazy seq for cheaper qualification checks
(-> []
(check-version version)
(check-file jar)
@@ -72,9 +80,14 @@
:transfer-listener :stdout
:repository {"releases" releases})))
-(defn promote [info]
- (when (empty? (blockers info))
- (deploy-to-s3 info)))
+(defn promote [{:keys [group name version] :as info}]
+ (sql/transaction
+ (when (empty? (blockers info))
+ (println "Promoting" info)
+ (update db/jars
+ (set-fields {:promoted_at (java.util.Date.)})
+ (where {:group_name group :jar_name name :version version}))
+ (deploy-to-s3 info))))
(defonce queue (LinkedBlockingQueue.))
Please sign in to comment.
Something went wrong with that request. Please try again.