SlHelpers
Loading...
Searching...
No Matches
DefaultFetchCallbacks.h
1// SPDX-License-Identifier: GPL-2.0-only
2
3#pragma once
4
5#include "../helpers/Ratelimit.h"
6#include "../helpers/SSH.h"
7
8#include "FetchCallbacks.h"
9
10namespace SlGit {
11
16public:
18 DefaultFetchCallbacks() : ratelimit(std::chrono::seconds(2)), tried(0), triedKey(0),
19 grabbedKeys(false) { }
20
21 virtual void checkoutProgress(std::string_view path, size_t completedSteps,
22 size_t totalSteps) override;
23
24 virtual int credentials(git_credential **out, std::string_view url,
25 std::optional<std::string_view> usernameFromUrl,
26 unsigned int allowedTypes) override;
27 virtual int packProgress(int stage, uint32_t current, uint32_t total) override;
28 virtual int sidebandProgress(std::string_view str) override;
29 virtual int transferProgress(const git_indexer_progress &stats) override;
30 virtual int updateRefs(std::string_view refname, const git_oid &a, const git_oid &b,
31 git_refspec &) override;
32
33private:
34 void getUserName(std::optional<std::string_view> usernameFromUrl);
35 std::string_view extractHost(std::string_view url);
36 void getKeys(std::string_view url);
37
38 std::string userName;
39 SlHelpers::Ratelimit ratelimit;
41 unsigned int tried;
42 unsigned int triedKey;
43 bool grabbedKeys;
44};
45
46}
virtual int sidebandProgress(std::string_view str) override
Callback for messages received by the transport.
virtual void checkoutProgress(std::string_view path, size_t completedSteps, size_t totalSteps) override
Called for each path in the tree.
DefaultFetchCallbacks()
Construct DefaultFetchCallbacks.
Definition DefaultFetchCallbacks.h:18
virtual int updateRefs(std::string_view refname, const git_oid &a, const git_oid &b, git_refspec &) override
Called for each updated reference.
virtual int packProgress(int stage, uint32_t current, uint32_t total) override
Called many times when packing objects.
virtual int transferProgress(const git_indexer_progress &stats) override
Called many times during download and indexing.
virtual int credentials(git_credential **out, std::string_view url, std::optional< std::string_view > usernameFromUrl, unsigned int allowedTypes) override
Fill in credentials.
FetchCallbacks()
Construct FetchCallbacks.
Definition FetchCallbacks.h:20
Rate-limit some actions.
Definition Ratelimit.h:12
std::vector< KeyPair > KeyPairs
A list of key pairs.
Definition SSH.h:24