You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
2.0 KiB
49 lines
2.0 KiB
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2018-2019 Lubuntu Team
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import git
|
|
import tempfile
|
|
from phabricator import Phabricator
|
|
|
|
RELEASE = ""
|
|
PASTRELEASE = ""
|
|
REPOLISTPATH = ""
|
|
CLONEBASE = ""
|
|
phab = Phabricator(host="" + "/api/", token="")
|
|
|
|
with tempfile.TemporaryDirectory() as workingdir:
|
|
for line in open(REPOLISTPATH):
|
|
repository = line.strip("\n")
|
|
print("Acting on " + repository + "...")
|
|
|
|
# Clone the repository and push the new branch
|
|
git.Git(workingdir).clone(CLONEBASE + repository + ".git")
|
|
gitrepo = git.Repo(workingdir + "/" + repository)
|
|
gitrepo.git.checkout("ubuntu/" + PASTRELEASE)
|
|
try:
|
|
gitrepo.git.branch("ubuntu/" + RELEASE)
|
|
except:
|
|
gitrepo.git.checkout("ubuntu/" + RELEASE)
|
|
gitrepo.git.push("--all")
|
|
print("Cloned " + repository + ".")
|
|
|
|
# Change the default branch in Phab and kick off an import
|
|
rename_result = phab.diffusion.repository.edit(transactions=[{"type": "defaultBranch", "value": "ubuntu/" + RELEASE}], objectIdentifier=phab.diffusion.repository.search(queryKey="active", constraints={"shortNames": [repository]})["data"][0]["phid"])
|
|
repo_id = rename_result["object"]["id"]
|
|
phab.diffusion.looksoon(repositories=[repository])
|
|
print("Changed the default branch of " + repository + " to ubuntu/" + RELEASE + " in Phab.")
|