diff --git a/currentGitHash.txt b/currentGitHash.txt index 0fe750350..d0a9d2d23 100644 --- a/currentGitHash.txt +++ b/currentGitHash.txt @@ -1 +1 @@ -88855207086c850b13d2f4479791532d76b9adb7 +73b8ddd08adf0d86ab70dcf464adaf9d5c604e41 diff --git a/hi_backend/backend/BackendApplicationCommands.cpp b/hi_backend/backend/BackendApplicationCommands.cpp index add88042c..887d2e113 100644 --- a/hi_backend/backend/BackendApplicationCommands.cpp +++ b/hi_backend/backend/BackendApplicationCommands.cpp @@ -1342,6 +1342,32 @@ void BackendCommandTarget::Actions::loadSnippet(BackendRootWindow* bpe, const St if (v.isValid()) { + auto hash = v["Hash"].toString(); + + WeakReference safeP(bpe->getMainSynthChain()); + + if(hash.isNotEmpty()) + { + GitHashManager::checkHash(hash, [safeP](const var& commitObj) + { + String message; + + auto hash = commitObj["sha"].toString(); + + auto date = commitObj["commit"]["author"]["date"].toString(); + + auto d = Time::fromISO8601(date); + + message << "Snippet loaded that was created with git commit \n"; + message << "> hash: " << hash.substring(0, 8) << "\n"; + message << "> date: " << d.toString(true, true, false, true) << "\n"; + message << "> message: " << commitObj["commit"]["message"].toString() << "\n"; + message << "> url: " << "https://github.com/christophhart/HISE/commit/" << hash; + + debugToConsole(safeP, message); + }); + } + bpe->loadNewContainer(v); } } @@ -1687,7 +1713,9 @@ String BackendCommandTarget::Actions::exportFileAsSnippet(BackendRootWindow* bpe MainController::ScopedEmbedAllResources sd(bp); ValueTree v = bp->getMainSynthChain()->exportAsValueTree(); - + + v.setProperty("Hash", String(PREVIOUS_HISE_COMMIT), nullptr); + auto scriptRootFolder = bp->getCurrentFileHandler().getSubDirectory(FileHandlerBase::Scripts); auto snexRootFolder = BackendDllManager::getSubFolder(bp, BackendDllManager::FolderSubType::CodeLibrary); @@ -3381,4 +3409,40 @@ String XmlBackupFunctions::getSanitiziedName(const String &id) return id.removeCharacters(" .()"); } +void GitHashManager::checkHash(const String& hashToUse, + const std::function& finishCallbackWithNextHash) +{ + Thread::launch([hashToUse, finishCallbackWithNextHash]() + { + var json; + + URL u("https://api.github.com/repos/christoph-hart/HISE/commits"); + + auto s = u.readEntireTextStream(); + + auto ok = JSON::parse(s, json); + + if(auto list = json.getArray()) + { + for(int i = 0; i < list->size(); i++) + { + auto thisSha = list->getUnchecked(i)["sha"].toString(); + + if(thisSha == hashToUse) + { + auto nextIndex = i-1; + + if(nextIndex >= 0 && isPositiveAndBelow(nextIndex, list->size())) + { + finishCallbackWithNextHash(list->getUnchecked(nextIndex)); + } + + break; + } + } + } + }); + + +} } // namespace hise diff --git a/hi_backend/backend/BackendApplicationCommands.h b/hi_backend/backend/BackendApplicationCommands.h index f1618db10..4c86a6341 100644 --- a/hi_backend/backend/BackendApplicationCommands.h +++ b/hi_backend/backend/BackendApplicationCommands.h @@ -452,6 +452,11 @@ struct XmlBackupFunctions static String getSanitiziedName(const String &id); }; +struct GitHashManager +{ + static void checkHash(const String& hashToUse, const std::function& finishCallbackWithNextHash); +}; + } // namespace hise #endif // BACKENDAPPLICATIONCOMMANDS_H_INCLUDED diff --git a/hi_backend/backend/currentGit.h b/hi_backend/backend/currentGit.h index 806d55af1..033b04765 100644 --- a/hi_backend/backend/currentGit.h +++ b/hi_backend/backend/currentGit.h @@ -1 +1 @@ -#define PREVIOUS_HISE_COMMIT "88855207086c850b13d2f4479791532d76b9adb7" +#define PREVIOUS_HISE_COMMIT "73b8ddd08adf0d86ab70dcf464adaf9d5c604e41" diff --git a/hi_backend/backend/dialog_library/dialog_library.cpp b/hi_backend/backend/dialog_library/dialog_library.cpp index 2128d2d89..203f8778a 100644 --- a/hi_backend/backend/dialog_library/dialog_library.cpp +++ b/hi_backend/backend/dialog_library/dialog_library.cpp @@ -312,60 +312,45 @@ var ExportSetupWizard::onPost(const var::NativeFunctionArgs& args) return var(); } + + var AboutWindow::initValues(const var::NativeFunctionArgs& args) { #define set(X) state->globalState.getDynamicObject()->setProperty(Identifier(#X), X); #define setXY(X, Y) state->globalState.getDynamicObject()->setProperty(Identifier(#X), Y); - auto hiseRoot = GET_HISE_SETTING(getMainController()->getMainSynthChain(), HiseSettings::Compiler::HisePath).toString(); - - + String buildHash(PREVIOUS_HISE_COMMIT); + + state->globalState.getDynamicObject()->setProperty("commitHash", "load current hash..."); + + WeakReference safeThis(this); + + GitHashManager::checkHash(buildHash, [safeThis](const var& commitObj) + { + if(safeThis.get() != nullptr) + { + auto nextHash = commitObj["sha"].toString(); + auto shortHash = nextHash.substring(0, 8); + + safeThis->state->globalState.getDynamicObject()->setProperty("commitHash", shortHash); + + if(auto pb = safeThis->dialog->findPageBaseForID("commitHash")) + { + MessageManagerLock mm; + pb->postInit(); + } + + String link; + link << "https://github.com/christophhart/HISE/commit/"; + link << nextHash; + + safeThis->commitLink = URL(link); + } + }); + - if(hiseRoot.isNotEmpty() && File::isAbsolutePath(hiseRoot)) - { - auto codeHash = File(hiseRoot).getChildFile("currentGitHash.txt").loadFileAsString().trim(); - - String buildHash(PREVIOUS_HISE_COMMIT); - - URL u("https://api.github.com/repos/christoph-hart/HISE/commits"); - - auto s = u.readEntireTextStream(); - - var json; - - auto ok = JSON::parse(s, json); - - if(auto list = json.getArray()) - { - for(int i = 0; i < list->size(); i++) - { - auto thisSha = list->getUnchecked(i)["sha"].toString(); - - if(thisSha == buildHash) - { - auto nextIndex = i-1; - - if(nextIndex >= 0 && isPositiveAndBelow(nextIndex, list->size())) - { - auto nextSHA = list->getUnchecked(nextIndex)["sha"].toString(); - - auto shortHash = nextSHA.substring(0, 8); - - state->globalState.getDynamicObject()->setProperty("commitHash", shortHash); - - String link; - link << "https://github.com/christophhart/HISE/commit/"; - link << nextSHA; - - commitLink = URL(link); - } - - break; - } - } - } - } + String Version = hise::PresetHandler::getVersionString(); diff --git a/hi_backend/backend/dialog_library/dialog_library.h b/hi_backend/backend/dialog_library/dialog_library.h index 5157f3424..4ec6da49e 100644 --- a/hi_backend/backend/dialog_library/dialog_library.h +++ b/hi_backend/backend/dialog_library/dialog_library.h @@ -133,6 +133,8 @@ struct AboutWindow: public multipage::EncodedDialogBase var showCommit(const var::NativeFunctionArgs& args); URL commitLink; + + JUCE_DECLARE_WEAK_REFERENCEABLE(AboutWindow); }; struct NewProjectCreator: public ImporterBase,