Misc cleanup (#1486)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled

* Skip non-directories when loading branches
* Warn if branch doesn't exist
* Add braces to globbing
This commit is contained in:
trapexit 2025-06-25 22:43:49 -05:00 • committed by GitHub
parent be49dbe1bd
commit 264c5600f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 173 deletions

View file

@ -54,7 +54,7 @@ Branches::Impl::operator=(Branches::Impl &rval_)
Branches::Impl&
Branches::Impl::operator=(Branches::Impl &&rval_)
{
using type = std::vector<Branch>;
using type = std::vector<Branch>;
auto this_base = dynamic_cast<type*>(this);
auto rval_base = dynamic_cast<type*>(&rval_);
@ -192,11 +192,27 @@ namespace l
fs::glob(glob,&paths);
if(paths.empty())
paths.push_back(glob);
{
SysLog::notice("branch glob `{}` found no matches,"
" adding the literal to branches",glob);
paths.push_back(glob);
}
fs::realpathize(&paths);
for(auto &path : paths)
{
std::error_code ec;
if(!std::filesystem::exists(path))
{
SysLog::notice("branch `{}` does not currently exist",path);
}
else if(!std::filesystem::is_directory(path,ec))
{
SysLog::warning("branch `{}` is not a directory, skipping",path);
continue;
}
branch.path = path;
branches_->emplace_back(branch);
}
@ -432,7 +448,7 @@ Branches::find_and_set_mode_ro()
if(!fs::is_rofs_but_not_mounted_ro(branch.path))
continue;
SysLog::warning("Branch {} found to be readonly - setting its mode to RO",
SysLog::warning("branch `{}` found to be readonly - setting its mode=RO",
branch.path);
branch.mode = Branch::Mode::RO;