File indexing completed on 2024-04-21 15:32:18
0001 // A try to port libgit2 status.c example to libqgit2 0002 0003 0004 #include "TestHelpers.h" 0005 0006 #include <QCoreApplication> 0007 #include <QPointer> 0008 #include <QTimer> 0009 #include <iostream> 0010 0011 #include <bitset> 0012 0013 #include "qgitcommit.h" 0014 #include "qgitrepository.h" 0015 #include "qgitrevwalk.h" 0016 0017 0018 using namespace LibQGit2; 0019 0020 0021 class TestRevision : public TestBase 0022 { 0023 Q_OBJECT 0024 0025 private slots: 0026 void init(); 0027 void cleanup(); 0028 0029 void revwalk(); 0030 0031 private: 0032 QPointer<Repository> repo; 0033 }; 0034 0035 void TestRevision::init() 0036 { 0037 TestBase::init(); 0038 0039 QVERIFY(!repo); 0040 0041 // Create a new repository object 0042 repo = new Repository(); 0043 0044 QVERIFY(repo); 0045 0046 try { 0047 // Open a local fixed path 0048 repo->open(ExistingRepository); 0049 } catch (const Exception& ex) { 0050 QFAIL(ex.what()); 0051 } 0052 } 0053 0054 void TestRevision::cleanup() 0055 { 0056 QVERIFY(repo); 0057 delete repo; 0058 QVERIFY(!repo); 0059 0060 TestBase::cleanup(); 0061 } 0062 0063 void TestRevision::revwalk() 0064 { 0065 try { 0066 0067 RevWalk rw(*repo); 0068 0069 rw.setSorting(RevWalk::Topological); 0070 0071 rw.pushHead(); 0072 0073 Commit commit; 0074 while(rw.next(commit)) { 0075 QByteArray qb = commit.oid().format(); 0076 std::cout << qb.data() << std::endl; 0077 } 0078 0079 } catch (const Exception& ex) { 0080 QFAIL(ex.what()); 0081 } 0082 } 0083 0084 QTEST_MAIN(TestRevision); 0085 0086 #include "Revision.moc"