mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-12 07:12:54 +01:00
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { Branch } from '../core/models/branch';
|
|
import { IPushProgress } from '../core/models/progress';
|
|
import { push as gitPush } from '../core/push';
|
|
import { createErrorFromMessage, GitActionError, GitActionErrorCode } from './git-action-error';
|
|
import { getRemote } from './remote';
|
|
|
|
interface PushOptions {
|
|
baseDir: string;
|
|
currentBranch: Branch;
|
|
|
|
onProgress?: (progress: IPushProgress) => void;
|
|
}
|
|
|
|
export async function push({ baseDir, currentBranch, onProgress }: PushOptions): Promise<boolean> {
|
|
const remote = await getRemote(baseDir);
|
|
|
|
try {
|
|
return await gitPush(
|
|
baseDir,
|
|
remote,
|
|
currentBranch.nameWithoutRemote,
|
|
currentBranch.upstreamWithoutRemote,
|
|
[],
|
|
undefined,
|
|
onProgress
|
|
);
|
|
} catch (error) {
|
|
const message = error.toString();
|
|
if (message.includes('Updates were rejected because the remote contains work that you do')) {
|
|
throw new Error(
|
|
'Updates were rejected because there are new changes that you do not have locally. Pull to get the latest changes.'
|
|
);
|
|
}
|
|
|
|
throw createErrorFromMessage(error.toString());
|
|
}
|
|
}
|