commit all archived files

This commit is contained in:
mappu 2013-09-21 00:53:49 +00:00
parent 76341bb409
commit ef3f3b6e9b

View File

@ -24,6 +24,7 @@ class CProjectGitExporter extends CProject {
$this->filterLongDescArea(); $this->filterLongDescArea();
// Prepare to start modifying the generated README.md file // 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 = explode("\n", $this->longdesc);
$lines = array_merge(["# ".$this->projname, ""], $lines); $lines = array_merge(["# ".$this->projname, ""], $lines);
@ -86,11 +87,17 @@ class CProjectGitExporter extends CProject {
// Extra properties file // Extra properties file
$ctime = $this->lastupdate - ($this->lifespan * 3600); // Lifespans are measured in hours $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 file_put_contents($dest.'/.legacy-codesite.toml', "# Converted with codesite2git
project_name=\"".$this->projname."\" project_name=".json_encode($this->projname)."
short_description=\"".$this->shortdesc."\" short_description=".json_encode($nice_shortdesc)."
written_in_lang=\"".$this->subtag."\" written_in_lang=".json_encode($this->subtag)."
topics=".json_encode($this->tags)." topics=".json_encode($this->tags)."
ctime=".$ctime." ctime=".$ctime."
mtime=".$this->lastupdate." mtime=".$this->lastupdate."
@ -134,20 +141,64 @@ function codesite2git(string $projdirname, string $projname, string $dest) {
// Parse existing project // Parse existing project
$c = new CProjectGitExporter($projdirname, $projname); $c = new CProjectGitExporter($projdirname, $projname);
var_dump($c); // var_dump($c);
$c->ExportAsGit($dest); $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) { function main(array $argv) {
if (count($argv) != 5) { if (count($argv) < 2) {
die("Usage: codesite2git CODESITE_ROOT_PATH PROJECT_DIR_NAME PROJECT_REAL_NAME DEST_DIR\n"); 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']); main($_SERVER['argv']);