Skip to content

Commit

Permalink
fix: add clone in subdirectory option to clone dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Oct 3, 2024
1 parent a4c7bdd commit 7d06750
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
3 changes: 2 additions & 1 deletion quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export default configure((/* ctx */) => {
// publicPath: '/',
// analyze: true,
env: {
APP_VERSION: packageInfo.version
APP_VERSION: packageInfo.version,
OS_PLATFORM: process.platform
},
// rawDefine: {}
// ignorePublicFolder: true,
Expand Down
30 changes: 27 additions & 3 deletions src/components/CloneRepositoryDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,21 @@ q-dialog(
no-caps
@click='browseTargetDir'
)
.row.q-mt-lg
.col
.text-body2 Clone in Subdirectory
.text-caption.text-grey-5 A subdirectory with the name of the repository will be created under the path selected above. This replicates the default behavior of Git.
.col-auto
q-toggle(
tabindex='4'
v-model='state.cloneInSubDir'
checked-icon='mdi-check'
unchecked-icon='mdi-close'
)
.row.q-mt-lg
.col
.text-body2 Switch Working Directory
.text-caption.text-grey-5 Automatically set the local target directory as the working directory.
.text-caption.text-grey-5 Automatically set the cloned repository path as the working directory.
.col-auto
q-toggle(
tabindex='4'
Expand Down Expand Up @@ -153,6 +164,7 @@ const state = reactive({
isFork: false,
upstreamUrl: '',
target: editorStore.workingDirectory,
cloneInSubDir: true,
switchWorkDir: true,
isLoading: false
})
Expand All @@ -162,7 +174,7 @@ const state = reactive({
async function cloneRepo () {
let progressDialog
try {
if (!state.url) {
if (!state.url || !state.url.startsWith('https://')) {
throw new Error('You must enter a valid HTTPS git repository URL!')
}
if (!state.target) {
Expand All @@ -179,9 +191,21 @@ async function cloneRepo () {
ok: false
})
await window.ipcBridge.gitCloneRepository(state.url, state.target, state.isFork ? state.upstreamUrl : null)
// -> Append repo to target path
let targetDir = state.target.trim()
if (state.cloneInSubDir) {
let lastUrlPart = state.url.split('/').at(-1)
if (lastUrlPart.endsWith('.git')) {
lastUrlPart = lastUrlPart.slice(0, -4)
}
targetDir = process.env.OS_PLATFORM === 'win32' ? `${targetDir}\\${lastUrlPart}` : `${targetDir}/${lastUrlPart}`
}
// -> Clone repo
await window.ipcBridge.gitCloneRepository(state.url, targetDir, state.isFork ? state.upstreamUrl : null)
state.isLoading = false
// -> Switch working directory
if (state.switchWorkDir) {
editorStore.workingDirectory = state.target
editorStore.drawerPane = 'DrawerFiles'
Expand Down
8 changes: 4 additions & 4 deletions src/components/PreferencesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,21 @@ q-dialog(
unchecked-icon='mdi-close'
)
.row(v-if='!editorStore.gitUseCredMan')
.col-8
.col-7
.text-body2 Username
.text-caption.text-grey-5 The username to use for git authentication.
.col-4
.col-5
q-input(
v-model.number='editorStore.gitUsername'
outlined
dense
color='light-blue-4'
)
.row(v-if='!editorStore.gitUseCredMan')
.col-8
.col-7
.text-body2 Password / Personal Access Token
.text-caption.text-grey-5 The password / PAT to use for git authentication
.col-4
.col-5
q-input(
v-model.number='editorStore.gitPassword'
:type='state.gitPasswordShown ? `text` : `password`'
Expand Down

0 comments on commit 7d06750

Please sign in to comment.