first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { TestError } from '../Types';
|
||||
import type { ApiHelpers } from './api-helper';
|
||||
|
||||
export class SourceControlApiHelper {
|
||||
constructor(private api: ApiHelpers) {}
|
||||
|
||||
async disconnect({ keepKeyPair = true }: { keepKeyPair?: boolean } = {}) {
|
||||
const response = await this.api.request.post('/rest/source-control/disconnect', {
|
||||
data: {
|
||||
keepKeyPair,
|
||||
},
|
||||
});
|
||||
if (!response.ok()) {
|
||||
throw new TestError(`Failed to disconnect from source control: ${await response.text()}`);
|
||||
}
|
||||
const result = await response.json();
|
||||
return result.data;
|
||||
}
|
||||
|
||||
async connect(preferences: {
|
||||
repositoryUrl: string;
|
||||
}) {
|
||||
const response = await this.api.request.post('/rest/source-control/preferences', {
|
||||
data: {
|
||||
connectionType: 'ssh',
|
||||
...preferences,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok()) {
|
||||
throw new TestError(`Failed to connect to source control: ${await response.text()}`);
|
||||
}
|
||||
const result = await response.json();
|
||||
return result.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will push all the changes
|
||||
* OPTIMIZE: add a fileNames to select what specific changes to push
|
||||
* @returns
|
||||
*/
|
||||
async pushWorkFolder({
|
||||
commitMessage,
|
||||
force = false,
|
||||
}: {
|
||||
commitMessage: string;
|
||||
force?: boolean;
|
||||
}) {
|
||||
const response = await this.api.request.post('/rest/source-control/push-workfolder', {
|
||||
data: {
|
||||
commitMessage,
|
||||
force,
|
||||
fileNames: [],
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok()) {
|
||||
throw new TestError(`Failed to push work folder: ${await response.text()}`);
|
||||
}
|
||||
const result = await response.json();
|
||||
return result.data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user