mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
refactor: git/storage -> git/index
This commit is contained in:
parent
93130c5634
commit
7611e6353a
23 changed files with 91 additions and 92 deletions
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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(
|
||||
() =>
|
||||
({
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Pr } from '../common';
|
||||
import GitStorage from '../git/storage';
|
||||
import GitStorage from '../git';
|
||||
|
||||
export interface BbsConfig {
|
||||
baseBranch: string;
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
59
lib/platform/git/__snapshots__/index.spec.ts.snap
Normal file
59
lib/platform/git/__snapshots__/index.spec.ts.snap
Normal file
|
@ -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]`;
|
|
@ -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]`;
|
|
@ -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();
|
|
@ -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,
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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(
|
||||
() =>
|
||||
({
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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/
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue