src/repo_scanner.h
browsing at commit = 55fa1ac0b398c748c7e2421b855a1606790cafc9
#pragma once
#include <map>
#include <string>
#include <vector>
// Discovers git repositories that are direct children of a root directory and
// keeps an immutable name -> absolute path mapping. The name (directory name)
// is the public identifier used in URLs.
class RepoScanner {
public:
explicit RepoScanner(std::string root);
// Repository names sorted alphabetically.
std::vector<std::string> names() const;
// Absolute path for a repository, or "" if the name is unknown.
std::string path_for(const std::string &name) const;
const std::string &root() const { return root_; }
private:
std::string root_;
std::map<std::string, std::string> repos_; // name -> path
};