diff --git a/lib/manager/composer/artifacts.spec.ts b/lib/manager/composer/artifacts.spec.ts index 60033b5845c38dc53e518af06341c970766179c4..1488b1ee350f76726db777f12d95827d2291995b 100644 --- a/lib/manager/composer/artifacts.spec.ts +++ b/lib/manager/composer/artifacts.spec.ts @@ -2,7 +2,7 @@ import { exec as _exec } from 'child_process'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/execUtil'; import { mocked, platform } from '../../../test/util'; -import { StatusResult } from '../../platform/git/storage'; +import { StatusResult } from '../../platform/git'; import { setUtilConfig } from '../../util'; import { BinarySource } from '../../util/exec/common'; import * as docker from '../../util/exec/docker'; diff --git a/lib/manager/gomod/artifacts.spec.ts b/lib/manager/gomod/artifacts.spec.ts index 22914528c809938648c4b6b9fbf59d7a81393401..dec48a418b69f4aa6bb8512d508327583d829eaa 100644 --- a/lib/manager/gomod/artifacts.spec.ts +++ b/lib/manager/gomod/artifacts.spec.ts @@ -3,7 +3,7 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/execUtil'; import { mocked, platform } from '../../../test/util'; -import { StatusResult } from '../../platform/git/storage'; +import { StatusResult } from '../../platform/git'; import { setUtilConfig } from '../../util'; import { BinarySource } from '../../util/exec/common'; import * as docker from '../../util/exec/docker'; diff --git a/lib/manager/pipenv/artifacts.spec.ts b/lib/manager/pipenv/artifacts.spec.ts index 5b176f7f10cfaf40e1a2d6d19d0c5231d08bc33d..084f94254b66fb0631f8616b565db18f6e4aef8b 100644 --- a/lib/manager/pipenv/artifacts.spec.ts +++ b/lib/manager/pipenv/artifacts.spec.ts @@ -3,7 +3,7 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/execUtil'; import { mocked, platform } from '../../../test/util'; -import { StatusResult } from '../../platform/git/storage'; +import { StatusResult } from '../../platform/git'; import { setUtilConfig } from '../../util'; import { BinarySource } from '../../util/exec/common'; import * as docker from '../../util/exec/docker'; diff --git a/lib/platform/azure/index.spec.ts b/lib/platform/azure/index.spec.ts index ae79418894ebb30828ac55a65f8a2dfd879960f0..16aba35f38bdcd028731bbf19d5196ee3e2cf497 100644 --- a/lib/platform/azure/index.spec.ts +++ b/lib/platform/azure/index.spec.ts @@ -15,14 +15,14 @@ describe('platform/azure', () => { jest.resetModules(); jest.mock('./azure-got-wrapper'); jest.mock('./azure-helper'); - jest.mock('../git/storage'); + jest.mock('../git'); jest.mock('../../util/host-rules'); hostRules = require('../../util/host-rules'); require('../../util/sanitize').sanitize = jest.fn((input) => input); azure = await import('.'); azureApi = require('./azure-got-wrapper'); azureHelper = require('./azure-helper'); - GitStorage = require('../git/storage').Storage; + GitStorage = require('../git').Storage; GitStorage.mockImplementation(() => ({ initRepo: jest.fn(), cleanRepo: jest.fn(), diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index f2e24997fbef578f2cb8be36f7659616264c45f6..af4f87ec9f156350bb854b1da603ed2a4e110c85 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -31,7 +31,7 @@ import { RepoParams, VulnerabilityAlert, } from '../common'; -import GitStorage, { StatusResult } from '../git/storage'; +import GitStorage, { StatusResult } from '../git'; import { smartTruncate } from '../utils/pr-body'; import * as azureApi from './azure-got-wrapper'; import * as azureHelper from './azure-helper'; diff --git a/lib/platform/bitbucket-server/index.spec.ts b/lib/platform/bitbucket-server/index.spec.ts index 5a824b49d9bd9a847917838f881ff72d3877c090..9b147416b53a1324d8bd31e9cd3084e85416261a 100644 --- a/lib/platform/bitbucket-server/index.spec.ts +++ b/lib/platform/bitbucket-server/index.spec.ts @@ -8,7 +8,7 @@ import { import { PR_STATE_CLOSED, PR_STATE_OPEN } from '../../constants/pull-requests'; import { BranchStatus } from '../../types'; import { Platform } from '../common'; -import { Storage } from '../git/storage'; +import { Storage } from '../git'; function repoMock( endpoint: URL | string, @@ -174,11 +174,11 @@ describe('platform/bitbucket-server', () => { httpMock.reset(); httpMock.setup(); jest.mock('delay'); - jest.mock('../git/storage'); + jest.mock('../git'); jest.mock('../../util/host-rules'); hostRules = require('../../util/host-rules'); bitbucket = await import('.'); - GitStorage = require('../git/storage').Storage; + GitStorage = require('../git').Storage; GitStorage.mockImplementation( () => ({ diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 3dbf30082c510c91daa3549fe77cbdfbd0b41d1d..106e20ad4e6b3ed64dcb4bc7658e748fb10dc779 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -34,7 +34,7 @@ import { RepoParams, VulnerabilityAlert, } from '../common'; -import GitStorage, { StatusResult } from '../git/storage'; +import GitStorage, { StatusResult } from '../git'; import { smartTruncate } from '../utils/pr-body'; import { BbbsRestPr, BbsConfig, BbsPr, BbsRestUserRef } from './types'; import * as utils from './utils'; diff --git a/lib/platform/bitbucket-server/types.ts b/lib/platform/bitbucket-server/types.ts index aafd4b7dbac115fb7388a0e100c33cecd54770d6..db1c5abf0ce470320f9ccf0ef2f2901d90a0f6ce 100644 --- a/lib/platform/bitbucket-server/types.ts +++ b/lib/platform/bitbucket-server/types.ts @@ -1,5 +1,5 @@ import { Pr } from '../common'; -import GitStorage from '../git/storage'; +import GitStorage from '../git'; export interface BbsConfig { baseBranch: string; diff --git a/lib/platform/bitbucket/index.spec.ts b/lib/platform/bitbucket/index.spec.ts index 55effefbe7e5110e34c2a7c89f42f7eb3f18aa6d..d9e266459a12ff90b0f6437c07823b6d00bab725 100644 --- a/lib/platform/bitbucket/index.spec.ts +++ b/lib/platform/bitbucket/index.spec.ts @@ -47,20 +47,20 @@ const commits = { describe('platform/bitbucket', () => { let bitbucket: Platform; let hostRules: jest.Mocked<typeof import('../../util/host-rules')>; - let GitStorage: jest.Mocked<import('../git/storage').Storage> & jest.Mock; + let GitStorage: jest.Mocked<import('../git').Storage> & jest.Mock; let logger: jest.Mocked<typeof _logger>; beforeEach(async () => { // reset module jest.resetModules(); httpMock.reset(); httpMock.setup(); - jest.mock('../git/storage'); + jest.mock('../git'); jest.mock('../../util/host-rules'); jest.mock('../../logger'); hostRules = require('../../util/host-rules'); bitbucket = await import('.'); logger = (await import('../../logger')).logger as any; - GitStorage = require('../git/storage').Storage; + GitStorage = require('../git').Storage; GitStorage.mockImplementation(() => ({ initRepo: jest.fn(), cleanRepo: jest.fn(), diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index cd5b87a0f3187a8d81c6301792636d8e1cb0e548..903a66b65cf7546b2fa7778cf5f1f2a29cea1011 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -29,7 +29,7 @@ import { RepoParams, VulnerabilityAlert, } from '../common'; -import GitStorage, { StatusResult } from '../git/storage'; +import GitStorage, { StatusResult } from '../git'; import { smartTruncate } from '../utils/pr-body'; import { readOnlyIssueBody } from '../utils/read-only-issue-body'; import * as comments from './comments'; diff --git a/lib/platform/bitbucket/utils.ts b/lib/platform/bitbucket/utils.ts index 8e3185d90a06d6e6a56570f8a818806b81f5c5ba..0c4e6b4a5d6b9f7a5598751922598cfcc454d491 100644 --- a/lib/platform/bitbucket/utils.ts +++ b/lib/platform/bitbucket/utils.ts @@ -4,7 +4,7 @@ import { BranchStatus } from '../../types'; import { HttpResponse } from '../../util/http'; import { BitbucketHttp } from '../../util/http/bitbucket'; import { Pr } from '../common'; -import { Storage } from '../git/storage'; +import { Storage } from '../git'; const bitbucketHttp = new BitbucketHttp(); diff --git a/lib/platform/git/__snapshots__/index.spec.ts.snap b/lib/platform/git/__snapshots__/index.spec.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..f068e0bb58571ad0bf3cd25b6025cb12464653a0 --- /dev/null +++ b/lib/platform/git/__snapshots__/index.spec.ts.snap @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`platform/git getBranchCommit(branchName) should throw if branch does not exist 1`] = `[Error: Cannot fetch commit for branch that does not exist: not_found]`; + +exports[`platform/git getBranchFiles(branchName, baseBranchName?) detects changed files 1`] = ` +Array [ + "some-new-file", +] +`; + +exports[`platform/git getBranchFiles(branchName, baseBranchName?) detects changed files compared to current base branch 1`] = ` +Array [ + "some-new-file", +] +`; + +exports[`platform/git getCommitMessages() returns commit messages 1`] = ` +Array [ + "master message", + "past message", +] +`; + +exports[`platform/git getFile(filePath, branchName) returns null for 404 1`] = `[Error: repository-changed]`; + +exports[`platform/git getFileList() should exclude submodules 1`] = ` +Array [ + ".gitmodules", + "file_to_delete", + "master_file", + "past_file", +] +`; + +exports[`platform/git getFileList() should return the correct files 1`] = ` +Array [ + "file_to_delete", + "master_file", + "past_file", +] +`; + +exports[`platform/git initRepo()) should fetch latest 1`] = ` +Array [ + "master message", + "past message", +] +`; + +exports[`platform/git initRepo()) should fetch latest 2`] = ` +Array [ + "past message2", + "master message", +] +`; + +exports[`platform/git isBranchStale() should throw if branch does not exist 1`] = `[Error: Cannot check staleness for branch that does not exist: not_found]`; + +exports[`platform/git setBaseBranch(branchName) should throw if branch does not exist 1`] = `[Error: config-validation]`; diff --git a/lib/platform/git/__snapshots__/storage.spec.ts.snap b/lib/platform/git/__snapshots__/storage.spec.ts.snap deleted file mode 100644 index 6d93d316576d080a454266777fd5fa35bc60e620..0000000000000000000000000000000000000000 --- a/lib/platform/git/__snapshots__/storage.spec.ts.snap +++ /dev/null @@ -1,59 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`platform/git/storage getBranchCommit(branchName) should throw if branch does not exist 1`] = `[Error: Cannot fetch commit for branch that does not exist: not_found]`; - -exports[`platform/git/storage getBranchFiles(branchName, baseBranchName?) detects changed files 1`] = ` -Array [ - "some-new-file", -] -`; - -exports[`platform/git/storage getBranchFiles(branchName, baseBranchName?) detects changed files compared to current base branch 1`] = ` -Array [ - "some-new-file", -] -`; - -exports[`platform/git/storage getCommitMessages() returns commit messages 1`] = ` -Array [ - "master message", - "past message", -] -`; - -exports[`platform/git/storage getFile(filePath, branchName) returns null for 404 1`] = `[Error: repository-changed]`; - -exports[`platform/git/storage getFileList() should exclude submodules 1`] = ` -Array [ - ".gitmodules", - "file_to_delete", - "master_file", - "past_file", -] -`; - -exports[`platform/git/storage getFileList() should return the correct files 1`] = ` -Array [ - "file_to_delete", - "master_file", - "past_file", -] -`; - -exports[`platform/git/storage initRepo()) should fetch latest 1`] = ` -Array [ - "master message", - "past message", -] -`; - -exports[`platform/git/storage initRepo()) should fetch latest 2`] = ` -Array [ - "past message2", - "master message", -] -`; - -exports[`platform/git/storage isBranchStale() should throw if branch does not exist 1`] = `[Error: Cannot check staleness for branch that does not exist: not_found]`; - -exports[`platform/git/storage setBaseBranch(branchName) should throw if branch does not exist 1`] = `[Error: config-validation]`; diff --git a/lib/platform/git/storage.spec.ts b/lib/platform/git/index.spec.ts similarity index 99% rename from lib/platform/git/storage.spec.ts rename to lib/platform/git/index.spec.ts index 7e1efd4a935c1c245e2d1ad2065e03e74d732f8d..6aa6a32cdd5aaa1cf7e6c52a574073ff99b39068 100644 --- a/lib/platform/git/storage.spec.ts +++ b/lib/platform/git/index.spec.ts @@ -1,9 +1,9 @@ import fs from 'fs-extra'; import Git from 'simple-git/promise'; import tmp from 'tmp-promise'; -import GitStorage from './storage'; +import GitStorage from '.'; -describe('platform/git/storage', () => { +describe('platform/git', () => { jest.setTimeout(15000); const git = new GitStorage(); diff --git a/lib/platform/git/storage.ts b/lib/platform/git/index.ts similarity index 100% rename from lib/platform/git/storage.ts rename to lib/platform/git/index.ts diff --git a/lib/platform/gitea/index.spec.ts b/lib/platform/gitea/index.spec.ts index b44eddadda5a26ecef70f73e62ce76176a335177..3479e56952e268776fc2aeea1458ade01a40cc38 100644 --- a/lib/platform/gitea/index.spec.ts +++ b/lib/platform/gitea/index.spec.ts @@ -25,8 +25,7 @@ describe('platform/gitea', () => { let gitea: Platform; let helper: jest.Mocked<typeof import('./gitea-helper')>; let logger: jest.Mocked<typeof _logger>; - let GitStorage: jest.Mocked<typeof import('../git/storage').Storage> & - jest.Mock; + let GitStorage: jest.Mocked<typeof import('../git').Storage> & jest.Mock; const mockCommitHash = '0d9c7726c3d628b7e28af234595cfd20febdbf8e'; @@ -174,13 +173,13 @@ describe('platform/gitea', () => { jest.resetModules(); jest.clearAllMocks(); jest.mock('./gitea-helper'); - jest.mock('../git/storage'); + jest.mock('../git'); jest.mock('../../logger'); gitea = await import('.'); helper = (await import('./gitea-helper')) as any; logger = (await import('../../logger')).logger as any; - GitStorage = (await import('../git/storage')).Storage as any; + GitStorage = (await import('../git')).Storage as any; GitStorage.mockImplementation(() => ({ initRepo: gsmInitRepo, diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index 9552a8e3fe6cc42571d806a3776d30e1f52a78e6..9bfe2e72e592b5aefe7e6e8fb36ac98ef2d41b25 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -34,7 +34,7 @@ import { RepoParams, VulnerabilityAlert, } from '../common'; -import GitStorage, { StatusResult } from '../git/storage'; +import GitStorage, { StatusResult } from '../git'; import { smartTruncate } from '../utils/pr-body'; import * as helper from './gitea-helper'; diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts index 567eaadfe7a7d8eb6ee01435b43fb7aa6560b7c8..ce5cf336c7b87e018e056c215a0080b4a50dcc67 100644 --- a/lib/platform/github/index.spec.ts +++ b/lib/platform/github/index.spec.ts @@ -14,7 +14,7 @@ const githubApiHost = 'https://api.github.com'; describe('platform/github', () => { let github: Platform; let hostRules: jest.Mocked<typeof import('../../util/host-rules')>; - let GitStorage: jest.Mock<typeof import('../git/storage')>; + let GitStorage: jest.Mock<typeof import('../git')>; beforeEach(async () => { // reset module jest.resetModules(); @@ -23,8 +23,8 @@ describe('platform/github', () => { jest.mock('../../util/host-rules'); github = await import('.'); hostRules = mocked(await import('../../util/host-rules')); - jest.mock('../git/storage'); - GitStorage = (await import('../git/storage')).Storage as any; + jest.mock('../git'); + GitStorage = (await import('../git')).Storage as any; GitStorage.mockImplementation( () => ({ diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index d45a87d29a569a8fa059b0d7f98a0902ebf312e1..3d6381109e32acb5649987ad7c9f7ec9fd201e27 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -44,7 +44,7 @@ import { RepoParams, VulnerabilityAlert, } from '../common'; -import GitStorage, { StatusResult } from '../git/storage'; +import GitStorage, { StatusResult } from '../git'; import { smartTruncate } from '../utils/pr-body'; import { BranchProtection, diff --git a/lib/platform/github/types.ts b/lib/platform/github/types.ts index 1dad39f300c75704477364114f6475c13307d444..7c8948b3d91a0212c37fa21ea0e491bb77d05a15 100644 --- a/lib/platform/github/types.ts +++ b/lib/platform/github/types.ts @@ -1,5 +1,5 @@ import { Pr } from '../common'; -import GitStorage from '../git/storage'; +import GitStorage from '../git'; // https://developer.github.com/v3/repos/statuses // https://developer.github.com/v3/checks/runs/ diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 4fdfdf8cd0afb5f68518d5fbe63b70b07fcf5faf..6341c5760e3dbdd9c7699c8cfa2b19d0f5403359 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -21,7 +21,7 @@ const gitlabApiHost = 'https://gitlab.com'; describe('platform/gitlab', () => { let gitlab: Platform; let hostRules: jest.Mocked<typeof _hostRules>; - let GitStorage: jest.Mocked<typeof import('../git/storage')> & jest.Mock; + let GitStorage: jest.Mocked<typeof import('../git')> & jest.Mock; beforeEach(async () => { // reset module jest.resetModules(); @@ -30,8 +30,8 @@ describe('platform/gitlab', () => { jest.mock('../../util/host-rules'); jest.mock('delay'); hostRules = require('../../util/host-rules'); - jest.mock('../git/storage'); - GitStorage = require('../git/storage').Storage; + jest.mock('../git'); + GitStorage = require('../git').Storage; GitStorage.mockImplementation(() => ({ initRepo: jest.fn(), cleanRepo: jest.fn(), diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index f3b61624f57f939f224053343743990ef4d28f7c..4d94406115bbaeaa85279ea348458f441f2e8098 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -38,7 +38,7 @@ import { RepoParams, VulnerabilityAlert, } from '../common'; -import GitStorage, { StatusResult } from '../git/storage'; +import GitStorage, { StatusResult } from '../git'; import { smartTruncate } from '../utils/pr-body'; const gitlabApi = new GitlabHttp(); diff --git a/lib/workers/branch/index.spec.ts b/lib/workers/branch/index.spec.ts index 55c9ad5ed7656ff8e645f1334eacecf3ab557728..83aadfb209a64d11e81199e8e0c946fe795f3ac7 100644 --- a/lib/workers/branch/index.spec.ts +++ b/lib/workers/branch/index.spec.ts @@ -11,7 +11,7 @@ import { } from '../../constants/pull-requests'; import * as _npmPostExtract from '../../manager/npm/post-update'; import { File } from '../../platform'; -import { StatusResult } from '../../platform/git/storage'; +import { StatusResult } from '../../platform/git'; import * as _exec from '../../util/exec'; import { BranchConfig, PrResult } from '../common'; import * as _prWorker from '../pr';