1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2015 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "RepositoryFixtures.h"
22 #include "GitRevRefBrowser.h"
24 class GitRevRefBrowserCBasicGitWithTestRepoFixture
: public CBasicGitWithTestRepoFixture
28 class GitRevRefBrowserCBasicGitWithTestRepoBareFixture
: public CBasicGitWithTestRepoBareFixture
32 INSTANTIATE_TEST_CASE_P(GitRevRefBrowser
, GitRevRefBrowserCBasicGitWithTestRepoFixture
, testing::Values(GIT_CLI
));
33 INSTANTIATE_TEST_CASE_P(GitRevRefBrowser
, GitRevRefBrowserCBasicGitWithTestRepoBareFixture
, testing::Values(GIT_CLI
));
35 static void GetGitRevRefMap()
37 g_Git
.SetConfigValue(_T("branch.master.description"), _T("test"));
38 g_Git
.SetConfigValue(_T("branch.subdir/branch.description"), _T("multi\nline"));
40 MAP_REF_GITREVREFBROWSER refMap
;
42 EXPECT_EQ(0, GitRevRefBrowser::GetGitRevRefMap(refMap
, err
));
43 EXPECT_TRUE(err
.IsEmpty());
44 EXPECT_EQ(11, refMap
.size());
46 GitRevRefBrowser rev
= refMap
[L
"refs/heads/master"];
47 EXPECT_STREQ(_T("7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6"), rev
.m_CommitHash
.ToString());
48 EXPECT_STREQ(_T("Sven Strickroth"), rev
.GetAuthorName());
49 EXPECT_STREQ(_T("2015-03-07 18:03:58"), rev
.GetAuthorDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
50 EXPECT_STREQ(_T("Changed ASCII file"), rev
.GetSubject());
51 EXPECT_STREQ(_T("refs/remotes/origin/master"), rev
.m_UpstreamRef
);
52 EXPECT_STREQ(_T("test"), rev
.m_Description
);
54 rev
= refMap
[L
"refs/heads/subdir/branch"];
55 EXPECT_STREQ(_T("4c5c93d2a0b368bc4570d5ec02ab03b9c4334d44"), rev
.m_CommitHash
.ToString());
56 EXPECT_STREQ(_T("Sven Strickroth"), rev
.GetAuthorName());
57 EXPECT_STREQ(_T("2015-03-16 12:52:29"), rev
.GetAuthorDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
58 EXPECT_STREQ(_T("Several actions"), rev
.GetSubject());
59 EXPECT_STREQ(_T(""), rev
.m_UpstreamRef
);
60 EXPECT_STREQ(_T("multi\nline"), rev
.m_Description
);
62 rev
= refMap
[L
"refs/tags/also-signed"];
63 EXPECT_STREQ(_T("e89cb722e0f9b2eb763bb059dc099ee6c502a6d8"), rev
.m_CommitHash
.ToString());
64 EXPECT_STREQ(_T(""), rev
.GetAuthorName());
65 EXPECT_TRUE(rev
.GetAuthorDate() == 0);
66 EXPECT_STREQ(_T("Also signed"), rev
.GetSubject());
67 EXPECT_STREQ(_T(""), rev
.m_UpstreamRef
);
68 EXPECT_STREQ(_T(""), rev
.m_Description
);
71 EXPECT_EQ(0, GitRevRefBrowser::GetGitRevRefMap(refMap
, err
, [](const CString
& refName
) { return wcsncmp(refName
, L
"refs/heads/", 11) == 0; }));
72 EXPECT_TRUE(err
.IsEmpty());
73 EXPECT_EQ(5, refMap
.size());
74 EXPECT_TRUE(refMap
.find(L
"refs/heads/master") != refMap
.end());
77 TEST_P(GitRevRefBrowserCBasicGitWithTestRepoFixture
, GetGitRevRefMap
)
82 TEST_P(GitRevRefBrowserCBasicGitWithTestRepoBareFixture
, GetGitRevRefMap
)