Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend tools to handle multiple files #509

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(GITTYUP_VERSION
string(TIMESTAMP CURR_YEAR "%Y")
add_compile_definitions(CURR_YEAR=${CURR_YEAR})
configure_file(${CMAKE_SOURCE_DIR}/LICENSE.md.in ${CMAKE_SOURCE_DIR}/LICENSE.md
@ONLY)
@ONLY NEWLINE_STYLE UNIX)

# Write version to file so it can be used also from external, for example in the
# github manifest
Expand Down
7 changes: 4 additions & 3 deletions dep/git/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ if(NOT USE_SYSTEM_GIT)
macro(add_helper NAME)
set(TARGET git-credential-${NAME})
add_executable(${TARGET} ${PATH}/${NAME}/${TARGET}.c)
set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
$<TARGET_FILE_DIR:gittyup>)
set_target_properties(
${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
$<TARGET_FILE_DIR:gittyup>/credential-helpers)

if(${ARGC} GREATER 1)
target_link_libraries(${TARGET} ${ARGV1})
Expand All @@ -14,7 +15,7 @@ if(NOT USE_SYSTEM_GIT)
if(NOT APPLE)
install(
TARGETS ${TARGET}
DESTINATION ${CMAKE_INSTALL_BINDIR}
DESTINATION ${CMAKE_INSTALL_BINDIR}/credential-helpers
COMPONENT ${GITTYUP_NAME})
endif()
endmacro()
Expand Down
7 changes: 1 addition & 6 deletions src/cred/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
if(WIN32)
set(CREDENTIAL_IMPL_FILE WinCred.cpp)
endif()

add_library(cred Cache.cpp Store.cpp CredentialHelper.cpp GitCredential.cpp
${CREDENTIAL_IMPL_FILE})
add_library(cred Cache.cpp Store.cpp CredentialHelper.cpp GitCredential.cpp)

target_link_libraries(cred conf git Qt5::Core)

Expand Down
9 changes: 1 addition & 8 deletions src/cred/CredentialHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "CredentialHelper.h"
#include "Cache.h"
#include "GitCredential.h"
#include "WinCred.h"
#include "Store.h"
#include "conf/Settings.h"
#include "git/Config.h"
Expand Down Expand Up @@ -45,13 +44,7 @@ CredentialHelper *CredentialHelper::instance() {
auto path =
QString::fromLocal8Bit(qgetenv("HOME") + "/.git-credentials");
instance = new Store(path);
}
#if defined(Q_OS_WIN)
else if (helperName == winCredStoreName) {
instance = new WinCred;
}
#endif
else {
} else {
instance = new GitCredential(helperName);
}
}
Expand Down
45 changes: 43 additions & 2 deletions src/cred/GitCredential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//

#include "GitCredential.h"
#include <QStandardPaths>
#include <QCoreApplication>
#include <QDir>
#include <QProcess>
Expand Down Expand Up @@ -92,6 +93,46 @@ bool GitCredential::store(const QString &url, const QString &username,
}

QString GitCredential::command() const {
QDir dir(QCoreApplication::applicationDirPath());
return dir.filePath(QString("git-credential-%1").arg(mName));
QString name = QString("git-credential-%1").arg(mName);
QDir appDir = QCoreApplication::applicationDirPath();
appDir.cd("credential-helpers");

// Prefer credential helpers directly installed into Gittyup's app dir
QString candidate =
QStandardPaths::findExecutable(name, QStringList(appDir.path()));
if (!candidate.isEmpty()) {
return candidate;
}

candidate = QStandardPaths::findExecutable(name);
if (!candidate.isEmpty()) {
return candidate;
}

#ifdef Q_OS_WIN
// Look for GIT CLI installation path
QString gitPath = QStandardPaths::findExecutable("git");
if (!gitPath.isEmpty()) {
QDir gitDir = QFileInfo(gitPath).dir();
if (gitDir.dirName() == "cmd" || gitDir.dirName() == "bin") {
gitDir.cdUp();

#ifdef Q_OS_WIN64
gitDir.cd("mingw64");
#else
gitDir.cd("mingw32");
#endif

gitDir.cd("bin");

candidate =
QStandardPaths::findExecutable(name, QStringList(gitDir.path()));
if (!candidate.isEmpty()) {
return candidate;
}
}
}
#endif

return name;
}
128 changes: 0 additions & 128 deletions src/cred/WinCred.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions src/cred/WinCred.h

This file was deleted.

Loading