File indexing completed on 2024-04-14 15:50:56

0001 /**
0002  * SPDX-FileCopyrightText: (C) 2014 Narfinger <Narfinger@users.noreply.github.com>
0003  * SPDX-FileCopyrightText: (C) 2014 Gleb Baryshev <gleb.baryshev@gmail.com>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef GITWRAPPER_H
0009 #define GITWRAPPER_H
0010 
0011 #include <QtCore/QMutex>
0012 
0013 class git_repository;
0014 class git_index;
0015 class BasketScene;
0016 
0017 /* Static class to encapsulate git operations
0018  *
0019  * the commit* operations check if the file or subfolder is newer than the git directory
0020  **/
0021 class GitWrapper
0022 {
0023 public:
0024     static QMutex gitMutex;
0025     static void initializeGitRepository(QString folder);
0026     static void commitBasketView();                           // commits the whole directory
0027     static void commitCreateBasket();                         // commits and checks baskets/baskets.xml
0028     static void commitDeleteBasket(QString basketFolderName); // deletes a basket directory
0029     static void commitBasket(BasketScene *basket);            // commits and checks baskets/$BASKETNAME
0030     static void commitTagsXml();                              // commits and checks baskets.xml
0031 
0032 private:
0033     static bool commitPattern(git_repository *repo, QString pattern = "*", QString message = "AutoCommit");
0034     static bool commitIndex(git_repository *repo, git_index *index, QString message = "AutoCommit");
0035     static void removeDeletedFromIndex(git_repository *repo, git_index *index);
0036     static git_repository *openRepository();
0037     static QDateTime getLastCommitDate(git_repository *repo);
0038     static void gitErrorHandling();
0039 };
0040 
0041 #endif // GITWRAPPER_H