同步操作将从 killf/cgit 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "cgit.hpp"#include <unistd.h>#include <memory.h>#include <iostream>#include <sstream>#define DEFAULT_GIT_FILE "/usr/bin/git"#define DEFAULT_GITHUB_URL "https://github.com/"#define DEFAULT_MIRROR_URL "https://github.com.cnpmjs.org/"namespace cgit {using namespace std;static string create_cmd(std::vector<string> &args) {std::ostringstream ss;for (const auto &s:args) {ss << "\"" << s << "\" ";}return ss.str();}const char *get_git_file() {char *file = getenv("GIT");return file ? file : DEFAULT_GIT_FILE;}int cgit_clone(vector<string> &args) {// 1.git clone https://github.com.cnpmjs.org/killf/cgit.gitstring old_url, new_url, folder_name;for (size_t i = 2; i < args.size(); i++) {if (args[i].startsWith(DEFAULT_GITHUB_URL)) {old_url = args[i];new_url = args[i].replace(0, strlen(DEFAULT_GITHUB_URL), DEFAULT_MIRROR_URL);auto index = old_url.find_last_of('/');if (index != std::string::npos) {folder_name = old_url.substr(index + 1);if (folder_name.endswith(".git")) {folder_name = folder_name.substr(0, folder_name.size() - 4);}}}}args[0] = get_git_file();auto cmd1 = create_cmd(args);auto err = system(cmd1.c_str());if (err != 0 || new_url.empty() || folder_name.empty())return err;// 2.cd cgiterr = chdir(folder_name.c_str());if (err != 0)return err;// 3.git remote set-url origin https://github.com/killf/cgit.gitauto cmd3 = "git remote set-url origin \"" + old_url + "\"";return system(cmd3.c_str());}int cgit_pull(vector<string> &args) {return 0;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。