Skip to content

Commit 1569e11

Browse files
committed
Merge branch 'dev' into early-unstable
2 parents a28a56c + ae474ba commit 1569e11

File tree

4 files changed

+98
-136
lines changed

4 files changed

+98
-136
lines changed

CHANGELOG.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

release/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "EmuDeck",
3-
"version": "2.2.20",
3+
"version": "2.2.21",
44
"description": "Play all your RetroGames",
55
"license": "MIT",
66
"author": {

src/main/main.ts

Lines changed: 95 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ ipcMain.on('git-magic', async (event, branch) => {
666666
let dir = path.join(app.getPath('appData'), '/EmuDeck/backend');
667667
if (os.platform().includes('win32')) {
668668
repo = 'https://github.com/EmuDeck/emudeck-we.git';
669-
dir = path.join(app.getPath('appData'), '/EmuDeck/backend');
670669
} else {
671670
dir = path.join(os.homedir(), '.config/EmuDeck/backend');
672671
}
@@ -679,113 +678,124 @@ ipcMain.on('git-magic', async (event, branch) => {
679678

680679
let status = await git.status({ fs, dir, filepath: 'README.md' });
681680
console.log({ status });
681+
//No backend? we clone it.
682682
if (status === 'absent') {
683+
await fs.rm(dir, { recursive: true, force: true }, (err) => {
684+
if (err) {
685+
// Ocurrió un error al eliminar el directorio
686+
console.error(`Error deleting: ${err}`);
687+
message = 'error';
688+
}
689+
message = 'success';
690+
// Directorio eliminado con éxito
691+
console.log('backend deleted 0');
692+
});
683693
await git
684694
.clone({
685695
fs,
686696
http,
687697
dir,
688698
url: repo,
689699
depth: 1,
690-
onMessage: console.log,
691700
})
692-
.then((message = 'success'))
693-
.catch((message = 'error'));
694-
} else {
695-
//Fetch of new branches
696-
await git.fetch({
697-
fs,
698-
http,
699-
dir,
700-
url: repo,
701-
depth: 1,
702-
tags: false,
703-
});
704-
705-
// Status Matrix Row Indexes (git reset)
706-
const FILEPATH = 0;
707-
const HEAD = 1;
708-
const WORKDIR = 2;
709-
const STAGE = 3;
710-
711-
// Status Matrix State
712-
const UNCHANGED = 1;
713-
714-
const allFiles = await git.statusMatrix({ dir, fs });
715-
// Get all files which have been modified or staged - does not include new untracked files or deleted files
716-
717-
const modifiedFiles = allFiles
718-
.filter((row) => row[WORKDIR] > UNCHANGED && row[STAGE] > UNCHANGED)
719-
.map((row) => row[FILEPATH]);
720-
721-
console.log({ modifiedFiles });
722-
723-
// Delete modified/staged files
724-
await Promise.all(modifiedFiles.map((path) => fs.promises.rm(path)));
701+
.then((message = 'success'));
725702

726-
await git.checkout({ dir, fs, ref: branch, force: true });
703+
console.log({ message });
704+
} else {
705+
//Git reset hard
706+
try {
707+
await git.checkout({
708+
fs,
709+
dir,
710+
ref: 'HEAD',
711+
force: true,
712+
});
713+
console.log('All changes discarded successfully.');
714+
} catch (error) {
715+
console.error('Error discarding all changes:', error);
716+
}
727717

728-
await git
729-
.pull({
718+
//Fetch of new branches
719+
try {
720+
await git.fetch({
730721
fs,
731722
http,
732723
dir,
733-
singleBranch: true,
724+
url: repo,
725+
depth: 1,
726+
tags: false,
727+
});
728+
//Switch to the proper branch
729+
await git.checkout({
730+
fs,
731+
dir,
732+
ref: branch,
733+
});
734+
//Pull
735+
await git.merge({
736+
fs,
737+
dir,
738+
ours: branch,
739+
theirs: `origin/${branch}`,
734740
author: { name: 'EmuDeck', email: '[email protected]' },
735-
})
736-
.then((message = 'success'));
737-
}
741+
});
742+
status = await git.status({ fs, dir, filepath: 'README.md' });
743+
if (status === 'absent' || status === '*deleted') {
744+
message = 'error';
745+
} else {
746+
message = 'success';
747+
}
738748

739-
status = await git.status({ fs, dir, filepath: 'README.md' });
740-
if (status === 'absent') {
741-
message = 'error';
742-
} else {
743-
message = 'success';
749+
status = await git.status({ fs, dir, filepath: '.git' });
750+
console.log('status2', { status });
751+
if (status === 'absent' || status === '*deleted') {
752+
message = 'error';
753+
} else {
754+
message = 'success';
755+
}
756+
} catch (error) {
757+
await fs.rm(dir, { recursive: true, force: true }, (err) => {
758+
if (err) {
759+
// Ocurrió un error al eliminar el directorio
760+
console.error(`Error deleting: ${err}`);
761+
}
762+
message = 'error';
763+
// Directorio eliminado con éxito
764+
console.log('backend deleted 1');
765+
});
766+
await git
767+
.clone({
768+
fs,
769+
http,
770+
dir,
771+
url: repo,
772+
depth: 1,
773+
})
774+
.then((message = 'success'));
775+
}
776+
if (message === 'error') {
777+
console.log('GIT ERRRORRR');
778+
//We delete the backend and we we force a reload
779+
await fs.rm(dir, { recursive: true, force: true }, (err) => {
780+
if (err) {
781+
// Ocurrió un error al eliminar el directorio
782+
console.error(`Error deleting: ${err}`);
783+
message = 'error';
784+
}
785+
message = 'success';
786+
// Directorio eliminado con éxito
787+
console.log('backend deleted 2');
788+
});
789+
message = 'error';
790+
}
744791
}
745-
746-
await git.checkout({
747-
fs,
748-
dir,
749-
ref: branch,
750-
});
751-
792+
console.log('GIT', { message });
752793
return exec(`${bashCommand}`, shellType, (error, stdout, stderr) => {
753794
logCommand(bashCommand, error, stdout, stderr);
754795
event.reply('git-magic', message);
755796
});
756-
757-
// const backChannel = 'check-git-status';
758-
// let bashCommand = `cd ~/.config/EmuDeck/backend && git status`;
759-
//
760-
// if (os.platform().includes('darwin')) {
761-
// bashCommand = `cd ~/.config/EmuDeck/backend && git status`;
762-
// }
763-
// if (os.platform().includes('win32')) {
764-
// bashCommand = `cd %userprofile% && cd AppData && cd Roaming && cd EmuDeck && cd backend && git status`;
765-
// }
766-
//
767-
// return exec(`${bashCommand}`, shellType, (error, stdout, stderr) => {
768-
// logCommand(bashCommand, error, stdout, stderr);
769-
// event.reply(backChannel, stdout);
770-
// });
771797
});
772798

773-
// Next release
774-
// ipcMain.on('pull', async (event, branch) => {
775-
// const branchGIT = branch;
776-
// const backChannel = 'pull';
777-
// const bashCommand = `API_pull "${branchGIT}"`;
778-
//
779-
// return exec(
780-
// `${startCommand} . ${allPath}; ${bashCommand} ${finishCommand}`,
781-
// shellType,
782-
// (error, stdout, stderr) => {
783-
// logCommand(bashCommand, error, stdout, stderr);
784-
// event.reply(backChannel, stdout);
785-
// }
786-
// );
787-
// });
788-
789799
ipcMain.on('branch', async (event) => {
790800
event.reply('branch-out', process.env.BRANCH);
791801
});

src/renderer/pages/CheckUpdatePage.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,14 @@ function CheckUpdatePage() {
494494
} else {
495495
const modalData = {
496496
active: true,
497-
header: <span className="h4">Ooops 😞</span>,
497+
header: <span className="h4">Ooopsie 😞</span>,
498498
body: (
499499
<p>
500500
There seems to be an issue downloading the backend. Please
501501
restart EmuDeck after testing your network is working
502502
</p>
503503
),
504+
footer: <span></span>,
504505
css: 'emumodal--xs',
505506
};
506507

0 commit comments

Comments
 (0)