From 804b8426a565fb0197bdedcea88a41ff0f3670f5 Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Sun, 6 Mar 2016 20:06:43 -0500 Subject: [PATCH 1/2] Fix pass-name in commit message on Windows Fix removal of path of a password store on Windows. Before the change: "Add for C:/Users//password-store/zzz/qqq using QtPass." After the change: "Add for zzz/qqq using QtPass." And the same for "Remove" messages. Use the same removal method in store model too. --- mainwindow.cpp | 11 +++++------ storemodel.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 4a71ca73a..c522403a7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -614,11 +614,11 @@ QString MainWindow::getDir(const QModelIndex &index, bool forPass) { return forPass ? "" : abspath; QFileInfo info = model.fileInfo(proxyModel.mapToSource(index)); QString filePath = - (info.isFile() ? info.absolutePath() : info.absoluteFilePath()) + '/'; + (info.isFile() ? info.absolutePath() : info.absoluteFilePath()); if (forPass) { - filePath.replace(QRegExp("^" + passStore), ""); - filePath.replace(QRegExp("^" + abspath), ""); + filePath = QDir(abspath).relativeFilePath(filePath); } + filePath += '/'; return filePath; } @@ -628,8 +628,8 @@ QString MainWindow::getFile(const QModelIndex &index, bool forPass) { return QString(); QString filePath = model.filePath(proxyModel.mapToSource(index)); if (forPass) { + filePath = QDir(passStore).relativeFilePath(filePath); filePath.replace(QRegExp("\\.gpg$"), ""); - filePath.replace(QRegExp("^" + passStore), ""); } return filePath; } @@ -1131,9 +1131,8 @@ void MainWindow::setPassword(QString file, bool overwrite, bool isNew = false) { if (!useWebDav && useGit) { if (!overwrite) executeWrapper(gitExecutable, "add \"" + file + '"'); - QString path = file; + QString path = QDir(passStore).relativeFilePath(file); path.replace(QRegExp("\\.gpg$"), ""); - path.replace(QRegExp("^" + passStore), ""); executeWrapper(gitExecutable, "commit \"" + file + "\" -m \"" + (overwrite ? "Edit" : "Add") + " for " + path + " using QtPass.\""); diff --git a/storemodel.cpp b/storemodel.cpp index ada0540eb..8e7d8345c 100644 --- a/storemodel.cpp +++ b/storemodel.cpp @@ -41,8 +41,8 @@ bool StoreModel::ShowThis(const QModelIndex index) const { } else { QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent()); QString path = fs->filePath(useIndex); + path = QDir(store).relativeFilePath(path); path.replace(QRegExp("\\.gpg$"), ""); - path.replace(QRegExp("^" + store), ""); retVal = path.contains(filterRegExp()); } return retVal; From 9e3b3c4db7502d59d56ee98d93166616593586e4 Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Sun, 6 Mar 2016 20:09:50 -0500 Subject: [PATCH 2/2] Remove leading space in "Remove" commit message --- mainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index c522403a7..4fa022111 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1204,7 +1204,7 @@ void MainWindow::on_deleteButton_clicked() { if (useGit) { executeWrapper(gitExecutable, "rm -f \"" + file + '"'); executeWrapper(gitExecutable, - "commit \"" + file + "\" -m \" Remove for " + + "commit \"" + file + "\" -m \"Remove for " + getFile(ui->treeView->currentIndex(), true) + " using QtPass.\""); if (autoPush) @@ -1227,7 +1227,7 @@ void MainWindow::on_deleteButton_clicked() { if (useGit) { executeWrapper(gitExecutable, "rm -rf \"" + file + '"'); executeWrapper(gitExecutable, - "commit \"" + file + "\" -m \" Remove for " + + "commit \"" + file + "\" -m \"Remove for " + getFile(ui->treeView->currentIndex(), true) + " using QtPass.\""); if (autoPush)