Skip to content

Commit 6d65bd9

Browse files
authored
refactor git pull (#364)
1 parent 62911b1 commit 6d65bd9

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

src/cmd/boinc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void Boinc::run() {
128128
const auto progs_dir = Setup::getProgramsHome();
129129
FolderLock lock(project_dir);
130130
if (Setup::existsProgramsHome() && // need to check again here
131-
!Git::git(progs_dir, "pull origin main -q --ff-only", false)) {
131+
!Setup::pullProgramsHome(false)) {
132132
Log::get().error("Failed to update programs repository", false);
133133
const auto age = getFileAgeInDays(progs_dir);
134134
Log::get().info("Programs directory age: " + std::to_string(age) +

src/oeis/oeis_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void OeisManager::update(bool force) {
392392
}
393393
Log::get().info(msg);
394394
// update programs repository using git pull
395-
Git::git(progs_dir, "pull origin main -q --ff-only");
395+
Setup::pullProgramsHome();
396396
}
397397

398398
// touch marker file to track the age (even in server mode)

src/sys/setup.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ void Setup::cloneProgramsHome(const std::string& git_url) {
160160
Git::clone(git_url, getLodaHome() + "programs");
161161
}
162162

163+
bool Setup::pullProgramsHome(bool fail_on_error) {
164+
return Git::git(getProgramsHome(), "pull origin main -q --ff-only",
165+
fail_on_error);
166+
}
167+
163168
void Setup::checkDir(const std::string& home) {
164169
if (!isDir(home)) {
165170
Log::get().error(

src/sys/setup.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class Setup {
4646
const std::string& git_url =
4747
"https://github.com/loda-lang/loda-programs.git");
4848

49+
static bool pullProgramsHome(bool fail_on_error = true);
50+
4951
static std::string getSetupValue(const std::string& key);
5052

5153
static bool getSetupFlag(const std::string& key, bool default_value);

0 commit comments

Comments
 (0)