Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 9403b11

Browse files
committed
Repository: add static method Repository::clone
1 parent aa37117 commit 9403b11

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

libGitWrap/Repository.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,30 @@ namespace Git
149149

150150
GW_PRIVATE_IMPL(Repository, Base)
151151

152+
/**
153+
* @brief Clone a Git repository.
154+
*
155+
* @param[in,out] result A Result object; see @ref GitWrapErrorHandling
156+
*
157+
* @param[in] from the URL to clone from
158+
*
159+
* @param[in] to the path to clone to
160+
*
161+
* @return the cloned repository
162+
*/
163+
Repository Repository::clone(Result& result, const QString& from, const QString& to)
164+
{
165+
GW_CHECK_RESULT(result, nullptr);
166+
167+
// TODO: setup clone options and callbacks
168+
169+
git_repository* clonedRepo = nullptr;
170+
result = git_clone(&clonedRepo, GW_StringFromQt(from), GW_StringFromQt(to), nullptr /*TODO: clone options*/);
171+
GW_CHECK_RESULT(result, nullptr);
172+
173+
return new Private(clonedRepo);
174+
}
175+
152176
/**
153177
* @brief Create a new repository
154178
*

libGitWrap/Repository.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ namespace Git
5050
GW_PRIVATE_DECL(Repository, Base, public)
5151

5252
public:
53+
static Repository clone(Result& result,
54+
const QString& from,
55+
const QString& to
56+
/*TODO: options*/);
57+
5358
static Repository create(Result& result,
5459
const QString& path,
5560
bool bare);

0 commit comments

Comments
 (0)