Rename variables
This commit is contained in:
parent
a47d217ab3
commit
3a2c590158
@ -116,8 +116,8 @@ func main() {
|
|||||||
os.Exit(10)
|
os.Exit(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
oldPackageRepos := make([]*models.Repository, 0, len(packages))
|
factoryRepos := make([]*models.Repository, 0, len(packages)*2)
|
||||||
newPackages := make([]string, 0, len(packages))
|
develProjectPackages := make([]string, 0, len(packages))
|
||||||
for _, pkg := range packages {
|
for _, pkg := range packages {
|
||||||
src_pkg_name := strings.Split(pkg, ":")
|
src_pkg_name := strings.Split(pkg, ":")
|
||||||
repo, err := client.Repository.RepoGet(
|
repo, err := client.Repository.RepoGet(
|
||||||
@ -125,29 +125,45 @@ func main() {
|
|||||||
WithDefaults().WithOwner("pool").WithRepo(src_pkg_name[0]),
|
WithDefaults().WithOwner("pool").WithRepo(src_pkg_name[0]),
|
||||||
r.DefaultAuthentication)
|
r.DefaultAuthentication)
|
||||||
|
|
||||||
|
rpm, rpmErr := client.Repository.RepoGet(
|
||||||
|
repository.NewRepoGetParams().WithDefaults().WithOwner("rpm").WithRepo(src_pkg_name[0]),
|
||||||
|
r.DefaultAuthentication)
|
||||||
|
|
||||||
|
if rpmErr == nil {
|
||||||
|
factoryRepos = append(factoryRepos, rpm.Payload)
|
||||||
|
} else {
|
||||||
|
if !errors.Is(rpmErr, &repository.RepoGetNotFound{}) {
|
||||||
|
log.Panicln(rpmErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("No RPM package?", src_pkg_name)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(err, &repository.RepoGetNotFound{}) {
|
if !errors.Is(err, &repository.RepoGetNotFound{}) {
|
||||||
log.Panicln(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Cannot find src package:", src_pkg_name)
|
log.Println("Cannot find src package:", src_pkg_name)
|
||||||
newPackages = append(newPackages, src_pkg_name[0])
|
develProjectPackages = append(develProjectPackages, src_pkg_name[0])
|
||||||
} else {
|
} else {
|
||||||
oldPackageRepos = append(oldPackageRepos, repo.Payload)
|
factoryRepos = append(factoryRepos, repo.Payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
log.Println("Num repos found:", len(oldPackageRepos))
|
log.Println("Num repos found:", len(factoryRepos))
|
||||||
|
|
||||||
|
oldPackageNames := make([]string, 0, len(factoryRepos))
|
||||||
|
for _, repo := range factoryRepos {
|
||||||
|
oldPackageNames = append(oldPackageNames, repo.Name)
|
||||||
|
}
|
||||||
|
slices.Sort(oldPackageNames)
|
||||||
|
oldPackageNames = slices.Compact(oldPackageNames)
|
||||||
|
copy(oldPackageNames[2:], oldPackageNames)
|
||||||
|
log.Println("Num of old packages:", len(oldPackageNames))
|
||||||
|
|
||||||
// fork packags from pool
|
// fork packags from pool
|
||||||
cmd := exec.Command("./git-importer", func(r []*models.Repository) []string {
|
cmd := exec.Command("./git-importer", append([]string{"-r", git.GitPath}, oldPackageNames...)...)
|
||||||
ret := make([]string, len(r)+2)
|
|
||||||
ret[0] = "-r"
|
|
||||||
ret[1] = git.GitPath
|
|
||||||
for i := range r {
|
|
||||||
ret[i+2] = r[i].Name
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}(oldPackageRepos)...)
|
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
log.Println(string(out))
|
log.Println(string(out))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -155,48 +171,56 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reposOK := true
|
reposOK := true
|
||||||
for i := range oldPackageRepos {
|
log.Println("adding remotes...")
|
||||||
pkg := oldPackageRepos[i]
|
for i := range factoryRepos {
|
||||||
|
pkg := factoryRepos[i]
|
||||||
|
|
||||||
// add remote repos
|
// add remote repos
|
||||||
out := git.GitExecWithOutputOrPanic(pkg.Name, "remote", "show", "-n")
|
out := git.GitExecWithOutputOrPanic(pkg.Name, "remote", "show", "-n")
|
||||||
if !slices.Contains(strings.Split(out, "\n"), "factory") {
|
switch pkg.Owner.UserName {
|
||||||
out := git.GitExecWithOutputOrPanic(pkg.Name, "remote", "add", "factory", pkg.CloneURL)
|
case "pool":
|
||||||
if len(strings.TrimSpace(out)) > 1 {
|
if !slices.Contains(strings.Split(out, "\n"), "factory") {
|
||||||
log.Println(out)
|
out := git.GitExecWithOutputOrPanic(pkg.Name, "remote", "add", "factory", pkg.CloneURL)
|
||||||
}
|
if len(strings.TrimSpace(out)) > 1 {
|
||||||
}
|
log.Println(out)
|
||||||
if !slices.Contains(strings.Split(out, "\n"), "rpm") {
|
}
|
||||||
out := git.GitExecWithOutputOrPanic(pkg.Name, "remote", "add", "rpm", "https://src.opensuse.org/rpm/"+pkg.Name+".git")
|
}
|
||||||
if len(strings.TrimSpace(out)) > 1 {
|
case "rpm":
|
||||||
log.Println(out)
|
if !slices.Contains(strings.Split(out, "\n"), "rpm") {
|
||||||
|
out := git.GitExecWithOutputOrPanic(pkg.Name, "remote", "add", "rpm", pkg.CloneURL)
|
||||||
|
if len(strings.TrimSpace(out)) > 1 {
|
||||||
|
log.Println(out)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out = git.GitExecWithOutputOrPanic(pkg.Name, "fetch", "--multiple", "factory", "rpm")
|
for _, pkgName := range oldPackageNames {
|
||||||
|
log.Println("fetching git:", pkgName)
|
||||||
|
out := git.GitExecWithOutputOrPanic(pkgName, "fetch", "--multiple", "factory", "rpm")
|
||||||
if len(strings.TrimSpace(out)) > 1 {
|
if len(strings.TrimSpace(out)) > 1 {
|
||||||
log.Println(out)
|
log.Println(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that nothing is broken with the update
|
// check that nothing is broken with the update
|
||||||
out = git.GitExecWithOutputOrPanic(pkg.Name, "rev-list", "factory")
|
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory")
|
||||||
old_revs := strings.Split(out, "\n")
|
old_revs := strings.Split(out, "\n")
|
||||||
out = git.GitExecWithOutputOrPanic(pkg.Name, "rev-list", "factory", "^factory/factory")
|
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory", "^factory/factory")
|
||||||
added_revs := strings.Split(out, "\n")
|
added_revs := strings.Split(out, "\n")
|
||||||
out = git.GitExecWithOutputOrPanic(pkg.Name, "rev-list", "factory", "^rpm/factory")
|
out = git.GitExecWithOutputOrPanic(pkgName, "rev-list", "factory", "^rpm/factory")
|
||||||
added_rpm_revs := strings.Split(out, "\n")
|
added_rpm_revs := strings.Split(out, "\n")
|
||||||
if len(added_revs) == len(old_revs) && len(added_rpm_revs) == len(old_revs) {
|
if len(added_revs) == len(old_revs) && len(added_rpm_revs) == len(old_revs) {
|
||||||
log.Printf("Something is wrong with rev-ist for (len %d): %s\n", len(added_revs), pkg.Name)
|
log.Printf("Something is wrong with rev-ist for (len %d): %s\n", len(added_revs), pkgName)
|
||||||
reposOK = false
|
reposOK = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args := make([]string, 4, len(newPackages)+4)
|
args := make([]string, 4, len(develProjectPackages)+4)
|
||||||
args[0] = "-p"
|
args[0] = "-p"
|
||||||
args[1] = prj
|
args[1] = prj
|
||||||
args[2] = "-r"
|
args[2] = "-r"
|
||||||
args[4] = git.GitPath
|
args[4] = git.GitPath
|
||||||
args = append(args, newPackages...)
|
args = append(args, develProjectPackages...)
|
||||||
cmd = exec.Command("./git-importer", args...)
|
cmd = exec.Command("./git-importer", args...)
|
||||||
out, err = cmd.CombinedOutput()
|
out, err = cmd.CombinedOutput()
|
||||||
log.Println(out)
|
log.Println(out)
|
||||||
@ -208,7 +232,7 @@ func main() {
|
|||||||
log.Println("aborting import due to broken repos above...")
|
log.Println("aborting import due to broken repos above...")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range oldPackageRepos {
|
for _, pkg := range factoryRepos {
|
||||||
// update package
|
// update package
|
||||||
fork, err := client.Repository.CreateFork(repository.NewCreateForkParams().
|
fork, err := client.Repository.CreateFork(repository.NewCreateForkParams().
|
||||||
WithOwner("pool").
|
WithOwner("pool").
|
||||||
@ -260,7 +284,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range newPackages {
|
for _, pkg := range develProjectPackages {
|
||||||
ret, err := client.Organization.CreateOrgRepo(organization.NewCreateOrgRepoParams().WithOrg(org).WithBody(
|
ret, err := client.Organization.CreateOrgRepo(organization.NewCreateOrgRepoParams().WithOrg(org).WithBody(
|
||||||
&models.CreateRepoOption{
|
&models.CreateRepoOption{
|
||||||
ObjectFormatName: "sha256",
|
ObjectFormatName: "sha256",
|
||||||
|
Loading…
Reference in New Issue
Block a user