From dd09707c200e8d0c9772c9bf7a6a1e734229eebb Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Sun, 3 Jun 2018 07:43:09 +0200
Subject: [PATCH] =?UTF-8?q?refactor:=20default=20versionScheme=20to=20?=
 =?UTF-8?q?=E2=80=98semver=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/manager/bazel/extract.js                  |  2 +-
 lib/manager/buildkite/extract.js              |  1 -
 lib/manager/meteor/extract.js                 |  1 -
 lib/manager/npm/extract/index.js              |  1 -
 lib/manager/nvm/extract.js                    |  1 -
 lib/manager/pip_requirements/extract.js       |  1 +
 lib/workers/repository/updates/flatten.js     |  1 +
 .../bazel/__snapshots__/extract.spec.js.snap  |  4 --
 .../__snapshots__/extract.spec.js.snap        |  6 ---
 .../meteor/__snapshots__/extract.spec.js.snap |  6 ---
 .../extract/__snapshots__/index.spec.js.snap  | 39 -------------------
 .../nvm/__snapshots__/extract.spec.js.snap    |  2 -
 .../__snapshots__/extract.spec.js.snap        |  1 +
 13 files changed, 4 insertions(+), 62 deletions(-)

diff --git a/lib/manager/bazel/extract.js b/lib/manager/bazel/extract.js
index e97b6c68f5..d4910d20ec 100644
--- a/lib/manager/bazel/extract.js
+++ b/lib/manager/bazel/extract.js
@@ -16,7 +16,7 @@ function extractDependencies(content) {
   const deps = [];
   definitions.forEach(def => {
     logger.debug({ def }, 'Checking bazel definition');
-    const dep = { def, versionScheme: 'semver' };
+    const dep = { def };
     let depName;
     let remote;
     let currentVersion;
diff --git a/lib/manager/buildkite/extract.js b/lib/manager/buildkite/extract.js
index 1e9e338be7..45849232e9 100644
--- a/lib/manager/buildkite/extract.js
+++ b/lib/manager/buildkite/extract.js
@@ -52,7 +52,6 @@ function extractDependencies(content) {
             lineNumber,
             depName,
             purl: repo ? 'pkg:github/' + repo : undefined,
-            versionScheme: 'semver',
             currentVersion,
             skipReason,
           });
diff --git a/lib/manager/meteor/extract.js b/lib/manager/meteor/extract.js
index 6da6fac89d..b11a086419 100644
--- a/lib/manager/meteor/extract.js
+++ b/lib/manager/meteor/extract.js
@@ -25,7 +25,6 @@ function extractDependencies(content) {
           depName,
           currentVersion,
           purl: `pkg:npm/${depName.replace('@', '%40')}`,
-          versionScheme: 'semver',
         };
       })
       .filter(dep => dep.depName && dep.currentVersion);
diff --git a/lib/manager/npm/extract/index.js b/lib/manager/npm/extract/index.js
index 9c51ca68eb..1d55191f9e 100644
--- a/lib/manager/npm/extract/index.js
+++ b/lib/manager/npm/extract/index.js
@@ -107,7 +107,6 @@ async function extractDependencies(content, packageFile, config) {
           const dep = {
             depType,
             depName,
-            versionScheme: 'semver',
           };
           // TODO: do we need to remove the equals?
           dep.currentVersion = version.trim().replace(/^=/, '');
diff --git a/lib/manager/nvm/extract.js b/lib/manager/nvm/extract.js
index f96c7c75c5..ce74a00ca4 100644
--- a/lib/manager/nvm/extract.js
+++ b/lib/manager/nvm/extract.js
@@ -9,7 +9,6 @@ function extractDependencies(content) {
     depName: 'node',
     currentVersion: content.trim(),
     purl: 'pkg:github/nodejs/node?clean=true',
-    versionScheme: 'semver',
   };
   if (!semver.isPinnedVersion(dep.currentVersion)) {
     dep.skipReason = 'unsupported-version';
diff --git a/lib/manager/pip_requirements/extract.js b/lib/manager/pip_requirements/extract.js
index 534c72639f..38cf797535 100644
--- a/lib/manager/pip_requirements/extract.js
+++ b/lib/manager/pip_requirements/extract.js
@@ -24,6 +24,7 @@ function extractDependencies(content) {
           depName: matches[1],
           currentVersion: matches[2],
           lineNumber,
+          versionScheme: 'pep440',
         }
       );
     })
diff --git a/lib/workers/repository/updates/flatten.js b/lib/workers/repository/updates/flatten.js
index e7cbbfc259..8257aa8526 100644
--- a/lib/workers/repository/updates/flatten.js
+++ b/lib/workers/repository/updates/flatten.js
@@ -37,6 +37,7 @@ function flattenUpdates(config, packageFiles) {
                   .replace(/\s+/g, '-')
                   .toLowerCase()
               : undefined;
+            update.versionScheme = update.versionScheme || 'semver';
             delete updateConfig.repoIsOnboarded;
             delete updateConfig.renovateJsonPresent;
             updates.push(updateConfig);
diff --git a/test/manager/bazel/__snapshots__/extract.spec.js.snap b/test/manager/bazel/__snapshots__/extract.spec.js.snap
index 0e61d0dcd9..72e84d0b72 100644
--- a/test/manager/bazel/__snapshots__/extract.spec.js.snap
+++ b/test/manager/bazel/__snapshots__/extract.spec.js.snap
@@ -14,7 +14,6 @@ Array [
     "depType": "git_repository",
     "purl": "pkg:github/bazelbuild/rules_nodejs",
     "remote": "https://github.com/bazelbuild/rules_nodejs.git",
-    "versionScheme": "semver",
   },
   Object {
     "currentVersion": "0.6.1",
@@ -28,7 +27,6 @@ Array [
     "depType": "git_repository",
     "purl": "pkg:github/bazelbuild/rules_typescript",
     "remote": "https://github.com/bazelbuild/rules_typescript.git",
-    "versionScheme": "semver",
   },
   Object {
     "currentVersion": "0.0.3",
@@ -42,7 +40,6 @@ Array [
     "depType": "git_repository",
     "purl": "pkg:github/bazelbuild/rules_sass",
     "remote": "https://github.com/bazelbuild/rules_sass.git",
-    "versionScheme": "semver",
   },
   Object {
     "currentVersion": "0.7.1",
@@ -56,7 +53,6 @@ Array [
     "depType": "http_archive",
     "purl": "pkg:github/bazelbuild/rules_go",
     "repo": "bazelbuild/rules_go",
-    "versionScheme": "semver",
   },
 ]
 `;
diff --git a/test/manager/buildkite/__snapshots__/extract.spec.js.snap b/test/manager/buildkite/__snapshots__/extract.spec.js.snap
index 3353f1db22..3b26a6cffb 100644
--- a/test/manager/buildkite/__snapshots__/extract.spec.js.snap
+++ b/test/manager/buildkite/__snapshots__/extract.spec.js.snap
@@ -8,7 +8,6 @@ Array [
     "lineNumber": 4,
     "purl": undefined,
     "skipReason": "invalid-version",
-    "versionScheme": "semver",
   },
   Object {
     "currentVersion": "v1.3.2",
@@ -16,7 +15,6 @@ Array [
     "lineNumber": 15,
     "purl": undefined,
     "skipReason": "git-plugin",
-    "versionScheme": "semver",
   },
   Object {
     "currentVersion": "v1.3.2",
@@ -24,7 +22,6 @@ Array [
     "lineNumber": 22,
     "purl": undefined,
     "skipReason": "unknown",
-    "versionScheme": "semver",
   },
 ]
 `;
@@ -37,7 +34,6 @@ Array [
     "lineNumber": 4,
     "purl": "pkg:github/buildkite-plugins/docker-compose-buildkite-plugin",
     "skipReason": undefined,
-    "versionScheme": "semver",
   },
   Object {
     "currentVersion": "v1.3.2",
@@ -45,7 +41,6 @@ Array [
     "lineNumber": 15,
     "purl": "pkg:github/buildkite-plugins/docker-compose-buildkite-plugin",
     "skipReason": undefined,
-    "versionScheme": "semver",
   },
 ]
 `;
@@ -58,7 +53,6 @@ Array [
     "lineNumber": 2,
     "purl": "pkg:github/abc/detect-clowns-buildkite-plugin",
     "skipReason": undefined,
-    "versionScheme": "semver",
   },
 ]
 `;
diff --git a/test/manager/meteor/__snapshots__/extract.spec.js.snap b/test/manager/meteor/__snapshots__/extract.spec.js.snap
index 503e784bf2..0c42ca630c 100644
--- a/test/manager/meteor/__snapshots__/extract.spec.js.snap
+++ b/test/manager/meteor/__snapshots__/extract.spec.js.snap
@@ -7,37 +7,31 @@ Object {
       "currentVersion": "0.2.0",
       "depName": "xml2js",
       "purl": "pkg:npm/xml2js",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.6.0",
       "depName": "xml-crypto",
       "purl": "pkg:npm/xml-crypto",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.1.19",
       "depName": "xmldom",
       "purl": "pkg:npm/xmldom",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "2.7.10",
       "depName": "connect",
       "purl": "pkg:npm/connect",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "2.6.4",
       "depName": "xmlbuilder",
       "purl": "pkg:npm/xmlbuilder",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.2.0",
       "depName": "querystring",
       "purl": "pkg:npm/querystring",
-      "versionScheme": "semver",
     },
   ],
 }
diff --git a/test/manager/npm/extract/__snapshots__/index.spec.js.snap b/test/manager/npm/extract/__snapshots__/index.spec.js.snap
index 535b6737e0..d948556309 100644
--- a/test/manager/npm/extract/__snapshots__/index.spec.js.snap
+++ b/test/manager/npm/extract/__snapshots__/index.spec.js.snap
@@ -8,14 +8,12 @@ Object {
       "depName": "angular",
       "depType": "dependencies",
       "purl": "pkg:npm/angular",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.6.0",
       "depName": "@angular/cli",
       "depType": "devDependencies",
       "purl": "pkg:npm/%40angular/cli",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "*",
@@ -23,28 +21,24 @@ Object {
       "depType": "devDependencies",
       "purl": "pkg:npm/foo",
       "skipReason": "any-version",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "file:../foo/bar",
       "depName": "bar",
       "depType": "devDependencies",
       "skipReason": "file",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "latest",
       "depName": "other",
       "depType": "devDependencies",
       "skipReason": "unknown-version",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": ">=1.7.0 <2.0.0",
       "depName": "atom",
       "depType": "engines",
       "skipReason": "unknown-engines",
-      "versionScheme": "semver",
     },
     Object {
       "commitMessageTopic": "Node.js",
@@ -55,7 +49,6 @@ Object {
         "enabled": false,
       },
       "purl": "pkg:github/nodejs/node?clean=true",
-      "versionScheme": "semver",
     },
     Object {
       "commitMessageTopic": "npm",
@@ -63,7 +56,6 @@ Object {
       "depName": "npm",
       "depType": "engines",
       "purl": "pkg:npm/npm",
-      "versionScheme": "semver",
     },
     Object {
       "commitMessageTopic": "Yarn",
@@ -72,7 +64,6 @@ Object {
       "depType": "engines",
       "purl": "pkg:github/yarnpkg/yarn?clean=true",
       "skipReason": "unknown-version",
-      "versionScheme": "semver",
     },
   ],
   "lernaClient": undefined,
@@ -98,70 +89,60 @@ Object {
       "depName": "autoprefixer",
       "depType": "dependencies",
       "purl": "pkg:npm/autoprefixer",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "~1.6.0",
       "depName": "bower",
       "depType": "dependencies",
       "purl": "pkg:npm/bower",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "13.1.0",
       "depName": "browserify",
       "depType": "dependencies",
       "purl": "pkg:npm/browserify",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.9.2",
       "depName": "browserify-css",
       "depType": "dependencies",
       "purl": "pkg:npm/browserify-css",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.22.0",
       "depName": "cheerio",
       "depType": "dependencies",
       "purl": "pkg:npm/cheerio",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.21.0",
       "depName": "config",
       "depType": "dependencies",
       "purl": "pkg:npm/config",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "^1.5.8",
       "depName": "angular",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.5.8",
       "depName": "angular-touch",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular-touch",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.5.8",
       "depName": "angular-sanitize",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular-sanitize",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "4.0.0-beta.1",
       "depName": "@angular/core",
       "depType": "devDependencies",
       "purl": "pkg:npm/%40angular/core",
-      "versionScheme": "semver",
     },
   ],
   "lernaClient": undefined,
@@ -207,70 +188,60 @@ Object {
       "depName": "autoprefixer",
       "depType": "dependencies",
       "purl": "pkg:npm/autoprefixer",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "~1.6.0",
       "depName": "bower",
       "depType": "dependencies",
       "purl": "pkg:npm/bower",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "13.1.0",
       "depName": "browserify",
       "depType": "dependencies",
       "purl": "pkg:npm/browserify",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.9.2",
       "depName": "browserify-css",
       "depType": "dependencies",
       "purl": "pkg:npm/browserify-css",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.22.0",
       "depName": "cheerio",
       "depType": "dependencies",
       "purl": "pkg:npm/cheerio",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.21.0",
       "depName": "config",
       "depType": "dependencies",
       "purl": "pkg:npm/config",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "^1.5.8",
       "depName": "angular",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.5.8",
       "depName": "angular-touch",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular-touch",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.5.8",
       "depName": "angular-sanitize",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular-sanitize",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "4.0.0-beta.1",
       "depName": "@angular/core",
       "depType": "devDependencies",
       "purl": "pkg:npm/%40angular/core",
-      "versionScheme": "semver",
     },
   ],
   "lernaClient": "npm",
@@ -296,70 +267,60 @@ Object {
       "depName": "autoprefixer",
       "depType": "dependencies",
       "purl": "pkg:npm/autoprefixer",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "~1.6.0",
       "depName": "bower",
       "depType": "dependencies",
       "purl": "pkg:npm/bower",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "13.1.0",
       "depName": "browserify",
       "depType": "dependencies",
       "purl": "pkg:npm/browserify",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.9.2",
       "depName": "browserify-css",
       "depType": "dependencies",
       "purl": "pkg:npm/browserify-css",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "0.22.0",
       "depName": "cheerio",
       "depType": "dependencies",
       "purl": "pkg:npm/cheerio",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.21.0",
       "depName": "config",
       "depType": "dependencies",
       "purl": "pkg:npm/config",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "^1.5.8",
       "depName": "angular",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.5.8",
       "depName": "angular-touch",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular-touch",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "1.5.8",
       "depName": "angular-sanitize",
       "depType": "devDependencies",
       "purl": "pkg:npm/angular-sanitize",
-      "versionScheme": "semver",
     },
     Object {
       "currentVersion": "4.0.0-beta.1",
       "depName": "@angular/core",
       "depType": "devDependencies",
       "purl": "pkg:npm/%40angular/core",
-      "versionScheme": "semver",
     },
   ],
   "lernaClient": undefined,
diff --git a/test/manager/nvm/__snapshots__/extract.spec.js.snap b/test/manager/nvm/__snapshots__/extract.spec.js.snap
index d909afc4e4..17f14ddc21 100644
--- a/test/manager/nvm/__snapshots__/extract.spec.js.snap
+++ b/test/manager/nvm/__snapshots__/extract.spec.js.snap
@@ -6,7 +6,6 @@ Array [
     "currentVersion": "8.4.0",
     "depName": "node",
     "purl": "pkg:github/nodejs/node?clean=true",
-    "versionScheme": "semver",
   },
 ]
 `;
@@ -18,7 +17,6 @@ Array [
     "depName": "node",
     "purl": "pkg:github/nodejs/node?clean=true",
     "skipReason": "unsupported-version",
-    "versionScheme": "semver",
   },
 ]
 `;
diff --git a/test/manager/pip_requirements/__snapshots__/extract.spec.js.snap b/test/manager/pip_requirements/__snapshots__/extract.spec.js.snap
index f63886ce8f..7613bfff8c 100644
--- a/test/manager/pip_requirements/__snapshots__/extract.spec.js.snap
+++ b/test/manager/pip_requirements/__snapshots__/extract.spec.js.snap
@@ -6,6 +6,7 @@ Array [
     "currentVersion": "0.3.1",
     "depName": "some-package",
     "lineNumber": 2,
+    "versionScheme": "pep440",
   },
 ]
 `;
-- 
GitLab