mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-12 15:22:55 +01:00
Initial commit
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>
This commit is contained in:
37
packages/noodl-git/src/actions/push.ts
Normal file
37
packages/noodl-git/src/actions/push.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user