From 73ae9790f994fe3f0194a5e225106c3dddb77d84 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 24 Feb 2025 13:11:25 +0000 Subject: [PATCH] hyprpm: add --hl-url for custom forks --- hyprpm/src/core/PluginManager.cpp | 10 ++++++---- hyprpm/src/core/PluginManager.hpp | 1 + hyprpm/src/main.cpp | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp index 80d0a4021..3343cbe0a 100644 --- a/hyprpm/src/core/PluginManager.cpp +++ b/hyprpm/src/core/PluginManager.cpp @@ -463,7 +463,9 @@ bool CPluginManager::updateHeaders(bool force) { return false; } - progress.printMessageAbove(statusString("!", Colors::YELLOW, "Cloning https://github.com/hyprwm/Hyprland, this might take a moment.")); + const auto& HL_URL = m_szCustomHlUrl.empty() ? "https://github.com/hyprwm/Hyprland" : m_szCustomHlUrl; + + progress.printMessageAbove(statusString("!", Colors::YELLOW, "Cloning {}, this might take a moment.", HL_URL)); const bool bShallow = (HLVER.branch == "main") && !m_bNoShallow; @@ -474,12 +476,12 @@ bool CPluginManager::updateHeaders(bool force) { if (m_bVerbose && bShallow) progress.printMessageAbove(verboseString("will shallow since: {}", SHALLOW_DATE)); - std::string ret = execAndGet(std::format("cd {} && git clone --recursive https://github.com/hyprwm/Hyprland hyprland-{}{}", getTempRoot(), USERNAME, - (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : ""))); + std::string ret = + execAndGet(std::format("cd {} && git clone --recursive {} hyprland-{}{}", getTempRoot(), HL_URL, USERNAME, (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : ""))); if (!std::filesystem::exists(WORKINGDIR)) { progress.printMessageAbove(failureString("Clone failed. Retrying without shallow.")); - ret = execAndGet(std::format("cd {} && git clone --recursive https://github.com/hyprwm/hyprland hyprland-{}", getTempRoot(), USERNAME)); + ret = execAndGet(std::format("cd {} && git clone --recursive {} hyprland-{}", getTempRoot(), HL_URL, USERNAME)); } if (!std::filesystem::exists(WORKINGDIR + "/.git")) { diff --git a/hyprpm/src/core/PluginManager.hpp b/hyprpm/src/core/PluginManager.hpp index a99d8e6eb..b159b9210 100644 --- a/hyprpm/src/core/PluginManager.hpp +++ b/hyprpm/src/core/PluginManager.hpp @@ -62,6 +62,7 @@ class CPluginManager { bool m_bVerbose = false; bool m_bNoShallow = false; + std::string m_szCustomHlUrl; // will delete recursively if exists!! bool createSafeDirectory(const std::string& path); diff --git a/hyprpm/src/main.cpp b/hyprpm/src/main.cpp index 887bb4361..9f2411b01 100644 --- a/hyprpm/src/main.cpp +++ b/hyprpm/src/main.cpp @@ -29,6 +29,7 @@ constexpr std::string_view HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager ┣ --verbose | -v → Enable too much logging ┣ --force | -f → Force an operation ignoring checks (e.g. update -f) ┣ --no-shallow | -s → Disable shallow cloning of Hyprland sources +┣ --hl-url | → Pass a custom hyprland source url ┗ )#"; @@ -45,6 +46,7 @@ int main(int argc, char** argv, char** envp) { std::vector command; bool notify = false, notifyFail = false, verbose = false, force = false, noShallow = false; + std::string customHlUrl; for (int i = 1; i < argc; ++i) { if (ARGS[i].starts_with("-")) { @@ -59,6 +61,13 @@ int main(int argc, char** argv, char** envp) { verbose = true; } else if (ARGS[i] == "--no-shallow" || ARGS[i] == "-s") { noShallow = true; + } else if (ARGS[i] == "--hl-url") { + if (i + 1 >= argc) { + std::println(stderr, "Missing argument for --hl-url"); + return 1; + } + customHlUrl = ARGS[i + 1]; + i++; } else if (ARGS[i] == "--force" || ARGS[i] == "-f") { force = true; std::println("{}", statusString("!", Colors::RED, "Using --force, I hope you know what you are doing.")); @@ -66,9 +75,8 @@ int main(int argc, char** argv, char** envp) { std::println(stderr, "Unrecognized option {}", ARGS[i]); return 1; } - } else { + } else command.push_back(ARGS[i]); - } } if (command.empty()) { @@ -76,9 +84,10 @@ int main(int argc, char** argv, char** envp) { return 1; } - g_pPluginManager = std::make_unique(); - g_pPluginManager->m_bVerbose = verbose; - g_pPluginManager->m_bNoShallow = noShallow; + g_pPluginManager = std::make_unique(); + g_pPluginManager->m_bVerbose = verbose; + g_pPluginManager->m_bNoShallow = noShallow; + g_pPluginManager->m_szCustomHlUrl = customHlUrl; if (command[0] == "add") { if (command.size() < 2) {