Skip to content

Commit 0a7d220

Browse files
committed
Check if stash exists
1 parent 6471fed commit 0a7d220

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

Discord-Bot/commands/utility/remove.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ module.exports = {
3636
async function uploadChanges(itemRemoved) {
3737
try {
3838
// Check if there are any updates to the repo then pull
39-
await git.add('../');
40-
await git.commit('Stashing changes before pull');
41-
await git.stash();
39+
const status = await git.status();
40+
if (status.files.length > 0) {
41+
await git.add('../');
42+
await git.commit('Stashing changes before pull');
43+
await git.stash();
44+
}
45+
4246
await git.pull('origin', process.env.GIT_BRANCH);
43-
await git.stash(['pop']);
47+
48+
if (status.files.length > 0) {
49+
await git.stash(['pop']);
50+
}
4451

4552
// Add changes, commit, and push
4653
await git.add('../');

Discord-Bot/events/interactionCreate.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,19 @@ module.exports = {
7676
async function uploadChanges(itemRemoved) {
7777
try {
7878
// Check if there are any updates to the repo then pull
79-
await git.add('../');
80-
await git.commit('Stashing changes before pull');
81-
await git.stash();
79+
const status = await git.status();
80+
if (status.files.length > 0) {
81+
await git.add('../');
82+
await git.commit('Stashing changes before pull');
83+
await git.stash();
84+
}
85+
8286
await git.pull('origin', process.env.GIT_BRANCH);
83-
await git.stash(['pop']);
84-
87+
88+
if (status.files.length > 0) {
89+
await git.stash(['pop']);
90+
}
91+
8592
await git.add('../');
8693
await git.commit(`Added ${itemRemoved} to the wishlist`);
8794
await git.push('origin', process.env.GIT_BRANCH);

0 commit comments

Comments
 (0)