feat: purge local repo action for git module

This commit is contained in:
NGPixel 2020-02-03 23:39:00 -05:00
parent b1c7edac90
commit e68932aa40
2 changed files with 11 additions and 2 deletions

View File

@ -109,3 +109,6 @@ actions:
- handler: importAll - handler: importAll
label: Import Everything label: Import Everything
hint: Will import all content currently in the local Git repository, regardless of the latest commit state. Useful for importing content from the remote repository created before git was enabled. hint: Will import all content currently in the local Git repository, regardless of the latest commit state. Useful for importing content from the remote repository created before git was enabled.
- handler: purge
label: Purge Local Repository
hint: If you have unrelated merge histories, clearing the local repository can resolve this issue. This will not affect the remote repository or perform any commit.

View File

@ -78,7 +78,7 @@ module.exports = {
} }
} }
if (this.config.sshPort <= 0) { if (this.config.sshPort <= 0) {
this.config.sshPort = 22 this.config.sshPort = 22
} }
await this.git.addConfig('core.sshCommand', `ssh -i "${this.config.sshPrivateKeyPath}" -o StrictHostKeyChecking=no -p ${this.config.sshPort}`) await this.git.addConfig('core.sshCommand', `ssh -i "${this.config.sshPrivateKeyPath}" -o StrictHostKeyChecking=no -p ${this.config.sshPort}`)
WIKI.logger.info('(STORAGE/GIT) Adding origin remote via SSH...') WIKI.logger.info('(STORAGE/GIT) Adding origin remote via SSH...')
@ -443,5 +443,11 @@ module.exports = {
await this.git.commit(`docs: add all untracked content`) await this.git.commit(`docs: add all untracked content`)
WIKI.logger.info('(STORAGE/GIT) All content is now tracked.') WIKI.logger.info('(STORAGE/GIT) All content is now tracked.')
},
async purge() {
WIKI.logger.info(`(STORAGE/GIT) Purging local repository...`)
await fs.emptyDir(this.repoPath)
WIKI.logger.info('(STORAGE/GIT) Local repository is now empty. Reinitializing...')
await this.init()
} }
} }