Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Calculate blockers to promotion.

  • Loading branch information...
commit 6a0bf19b059935463b8bed935407f774da3f0417 1 parent e07674e
@technomancy authored
View
55 dev-resources/hooke-1.1.2.pom
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>robert</groupId>
+ <artifactId>hooke</artifactId>
+ <version>1.1.2</version>
+ <name>hooke</name>
+ <description>Hooke your functions!</description>
+ <scm>
+ <connection>scm:git:git://github.com/technomancy/robert-hooke.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/technomancy/robert-hooke.git</developerConnection>
+ <tag>19ce36f7a3b0704cdcde821ebf4b4721ec903efb</tag>
+ <url>https://github.com/technomancy/robert-hooke</url>
+ </scm>
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>test</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>test-resources</directory>
+ </testResource>
+ </testResources>
+ </build>
+ <repositories>
+ <repository>
+ <id>central</id>
+ <url>http://repo1.maven.org/maven2</url>
+ </repository>
+ <repository>
+ <id>clojure</id>
+ <url>http://build.clojure.org/releases</url>
+ </repository>
+ <repository>
+ <id>clojure-snapshots</id>
+ <url>http://build.clojure.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>clojars</id>
+ <url>http://clojars.org/repo/</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.clojure</groupId>
+ <artifactId>clojure</artifactId>
+ <version>1.3.0-beta1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
View
77 dev-resources/hooke-1.2.0-SNAPSHOT.pom
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>robert</groupId>
+ <artifactId>hooke</artifactId>
+ <packaging>jar</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>hooke</name>
+ <description>Hooke your functions!</description>
+ <url>https://github.com/technomancy/robert-hooke</url>
+ <licenses>
+ <license>
+ <name>Eclipse Public License</name>
+ <url>http://www.eclipse.org/legal/epl-v10.html</url>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:git:git://github.com/technomancy/robert-hooke.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/technomancy/robert-hooke.git</developerConnection>
+ <tag>727961c5242de367f233c50fd789a0670780e1b9</tag>
+ <url>https://github.com/technomancy/robert-hooke</url>
+ </scm>
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>test</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>dev-resources</directory>
+ </testResource>
+ <testResource>
+ <directory>resources</directory>
+ </testResource>
+ </testResources>
+ <directory>target</directory>
+ <outputDirectory>target/classes</outputDirectory>
+ </build>
+ <repositories>
+ <repository>
+ <id>central</id>
+ <url>http://repo1.maven.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>clojars</id>
+ <url>https://clojars.org/repo/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.clojure</groupId>
+ <artifactId>clojure</artifactId>
+ <version>1.4.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
+
+<!-- This file was autogenerated by Leiningen.
+ Please do not edit it directly; instead edit project.clj and regenerate it.
+ It should not be considered canonical data. For more information see
+ https://github.com/technomancy/leiningen -->
View
50 src/clojars/promote.clj
@@ -0,0 +1,50 @@
+(ns clojars.promote
+ (:require [clojars.config :refer [config]]
+ [clojars.maven :as maven]
+ [clojure.java.io :as io])
+ (:import (java.util.concurrent ArrayBlockingQueue)))
+
+(defn file-for [group artifact version extension]
+ (let [filename (format "%s-%s.%s" artifact version extension)]
+ (io/file (config :repo) group artifact version filename)))
+
+(defn check-file [blockers file]
+ (if (.exists file)
+ blockers
+ (conj blockers (str "Missing file " (.getName file)))))
+
+(defn check-version [blockers version]
+ (if (re-find #"-SNAPSHOT$" version)
+ (conj blockers "Snapshot versions cannot be promoted")
+ blockers))
+
+(defn check-field [blockers info field]
+ (if (field info)
+ blockers
+ (conj blockers (str "Missing " (name field)))))
+
+(defn signed? [blockers file]
+ ;; TODO: implement
+ blockers)
+
+(defn unpromoted? [blockers info]
+ ;; TODO implement
+ blockers)
+
+(defn blockers [file]
+ (let [{:keys [group name version] :as info} (maven/pom-to-map file)
+ jar (file-for group name version "jar")
+ pom (file-for group name version "pom")]
+ (-> []
+ (check-version (:version info))
+ (check-file jar)
+ (check-file pom)
+
+ (check-field info :description)
+ (check-field info :url)
+ (check-field info :licenses)
+ (check-field info :scm)
+
+ (signed? jar)
+ (signed? pom)
+ (unpromoted? info))))
View
18 test/clojars/test/unit/promote.clj
@@ -0,0 +1,18 @@
+(ns clojars.test.unit.promote
+ (:require [clojure.test :refer :all]
+ [clojars.promote :refer :all]
+ [clojure.java.io :as io]
+ [clojars.maven :as maven]))
+
+(deftest test-snapshot-blockers
+ (is (= ["Snapshot versions cannot be promoted"
+ "Missing file hooke-1.2.0-SNAPSHOT.jar"
+ "Missing file hooke-1.2.0-SNAPSHOT.pom"]
+ (blockers (io/resource "hooke-1.2.0-SNAPSHOT.pom")))))
+
+(deftest test-metadata-blockers
+ (.mkdirs (.getParentFile (file-for "robert" "hooke" "1.1.2" "pom")))
+ (spit (file-for "robert" "hooke" "1.1.2" "pom") "")
+ (spit (file-for "robert" "hooke" "1.1.2" "jar") "")
+ (is (= ["Missing url"]
+ (blockers (io/resource "hooke-1.1.2.pom")))))
Please sign in to comment.
Something went wrong with that request. Please try again.