commit all archived files
This commit is contained in:
parent
76341bb409
commit
ef3f3b6e9b
69
codesite2git
69
codesite2git
@ -24,6 +24,7 @@ class CProjectGitExporter extends CProject {
|
||||
$this->filterLongDescArea();
|
||||
|
||||
// Prepare to start modifying the generated README.md file
|
||||
$this->longdesc = preg_replace('~\\[url=([^\\]]+?)\\](.+?)\\[/url\\]~m', '[\\2](\\1)', $this->longdesc);
|
||||
$lines = explode("\n", $this->longdesc);
|
||||
$lines = array_merge(["# ".$this->projname, ""], $lines);
|
||||
|
||||
@ -86,11 +87,17 @@ class CProjectGitExporter extends CProject {
|
||||
|
||||
// Extra properties file
|
||||
$ctime = $this->lastupdate - ($this->lifespan * 3600); // Lifespans are measured in hours
|
||||
$nice_shortdesc = $this->shortdesc;
|
||||
if (strlen($nice_shortdesc) > 0) {
|
||||
$nice_shortdesc = rtrim($this->shortdesc, '.').'.';
|
||||
$nice_shortdesc[0] = strtoupper($nice_shortdesc[0]);
|
||||
}
|
||||
|
||||
file_put_contents($dest.'/.legacy-codesite.toml', "# Converted with codesite2git
|
||||
|
||||
project_name=\"".$this->projname."\"
|
||||
short_description=\"".$this->shortdesc."\"
|
||||
written_in_lang=\"".$this->subtag."\"
|
||||
project_name=".json_encode($this->projname)."
|
||||
short_description=".json_encode($nice_shortdesc)."
|
||||
written_in_lang=".json_encode($this->subtag)."
|
||||
topics=".json_encode($this->tags)."
|
||||
ctime=".$ctime."
|
||||
mtime=".$this->lastupdate."
|
||||
@ -134,20 +141,64 @@ function codesite2git(string $projdirname, string $projname, string $dest) {
|
||||
|
||||
// Parse existing project
|
||||
$c = new CProjectGitExporter($projdirname, $projname);
|
||||
var_dump($c);
|
||||
|
||||
// var_dump($c);
|
||||
$c->ExportAsGit($dest);
|
||||
}
|
||||
|
||||
function usage() {
|
||||
die("Usage:
|
||||
codesite2git [FLAGS...]
|
||||
|
||||
Options:
|
||||
--single CODESITE_ROOT_PATH PROJECT_DIR_NAME PROJECT_REAL_NAME DEST_DIR
|
||||
--all CODESITE_ROOT_PATH TEMP_DIR GITEA_URL GITEA_ORG GITEA_AUTH_TOKEN
|
||||
");
|
||||
die(1);
|
||||
}
|
||||
|
||||
function main(array $argv) {
|
||||
if (count($argv) != 5) {
|
||||
die("Usage: codesite2git CODESITE_ROOT_PATH PROJECT_DIR_NAME PROJECT_REAL_NAME DEST_DIR\n");
|
||||
if (count($argv) < 2) {
|
||||
usage();
|
||||
}
|
||||
|
||||
$config = setup_vars($argv[1]);
|
||||
if ($argv[1] == '--single') {
|
||||
if (count($argv) != 6) {
|
||||
usage();
|
||||
}
|
||||
|
||||
codesite2git($argv[2], $argv[3], $argv[4]);
|
||||
$config = setup_vars($argv[2]);
|
||||
codesite2git($argv[3], $argv[4], $argv[5]);
|
||||
|
||||
} else if ($argv[1] == "--all") {
|
||||
if (count($argv) != 7) {
|
||||
usage();
|
||||
}
|
||||
|
||||
$config = setup_vars($argv[2]);
|
||||
$repos = glob(BASEDIR.'data/*');
|
||||
|
||||
$temp_dir = $argv[3];
|
||||
|
||||
foreach($repos as $path) {
|
||||
$projdir = basename($path);
|
||||
$reponame = explode('-', $projdir, 2)[1];
|
||||
|
||||
// Convert to git
|
||||
codesite2git($projdir, $reponame, $temp_dir.'/'.$projdir.'-archive.git');
|
||||
|
||||
// Create new Gitea repo
|
||||
// TODO
|
||||
|
||||
// Add git remote and push
|
||||
// TODO
|
||||
|
||||
// Set Gitea topics + description
|
||||
// TODO
|
||||
}
|
||||
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
main($_SERVER['argv']);
|
||||
|
Reference in New Issue
Block a user