SlHelpers
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 
10 namespace SlGit {
11 
16 public:
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 
33 private:
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 }
Definition: Blob.h:11
DefaultFetchCallbacks()
Construct DefaultFetchCallbacks.
Definition: DefaultFetchCallbacks.h:18
Rate-limit some actions.
Definition: Ratelimit.h:12
Callbacks invoked from Repo::clone() or Remote::fetchRefspecs()
Definition: FetchCallbacks.h:17
std::vector< KeyPair > KeyPairs
A list of key pairs.
Definition: SSH.h:24
The default FetchCallbacks implementation.
Definition: DefaultFetchCallbacks.h:15