Skip to content
Snippets Groups Projects
Commit f80acbaf authored by Federico Mena Quintero's avatar Federico Mena Quintero
Browse files

Use --target-project instead of --target-product, per Gitlab's terminology

And change the descriptions in README.md to match this.  We want to
make it clear to the user that Bugzilla calls them "products" while
Gitlab calls them "projects".
parent 8aa2a0a0
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,7 @@ You will get some output:
```
Connecting to https://gitlab-test.gnome.org/
Using target product 'username/myproject since --target_product was not provided
Using target project 'username/myproject since --target-project was not provided
Connecting to bugzilla.gnome.org
WARNING: Bugzilla credentials were not provided, BZ bugs won't be closed and subscribers won't notice the migration
Querying for open bugs for the 'myproject' product
......@@ -126,6 +126,7 @@ If you get an error, check the following:
`--product` option.
* Is the Gitlab project name correct? If it is different from
Bugzilla's product name, you can use the `--target_product` option.
Bugzilla's product name, you can use the
`--target-project=username/project` option.
[installation]: #installation
......@@ -78,25 +78,25 @@ GIT_ORIGIN_PREFIX = 'https://git.gnome.org/browse/'
class GitLab:
GITLABURL = "https://gitlab-test.gnome.org/"
def __init__(self, token, product, target_product=None, automate=False):
def __init__(self, token, product, target_project=None, automate=False):
self.gl = None
self.token = token
self.product = product
self.target_product = target_product
self.target_project = target_project
self.automate = automate
def connect(self):
print("Connecting to %s" % self.GITLABURL)
self.gl = gitlab.Gitlab(self.GITLABURL, self.token)
self.gl.auth()
# If not target product was given, set the project under the user
# If not target project was given, set the project under the user
# namespace
if self.target_product is None:
self.target_product = self.gl.user.username + '/' + self.product
print("Using target product '{}' since --target-product was not provided".format(self.target_product))
if self.target_project is None:
self.target_project = self.gl.user.username + '/' + self.product
print("Using target project '{}' since --target-project was not provided".format(self.target_project))
def get_project(self):
return self.gl.projects.get(self.target_product)
return self.gl.projects.get(self.target_project)
def create_issue(self, id, summary, description, labels, creation_time):
return self.get_project().issues.create({
......@@ -132,7 +132,7 @@ class GitLab:
def import_project(self):
import_url = GIT_ORIGIN_PREFIX + self.product
print('Importing project from ' + import_url +
' to ' + self.target_product)
' to ' + self.target_project)
try:
project = self.get_project()
......@@ -437,7 +437,7 @@ def options():
description="Bugzilla migration helper for bugzilla.gnome.org "
"products")
parser.add_argument('--production', action='store_true',
help="target production instead of testing")
help="target production (gitlab.gnome.org) instead of testing (gitlab-test.gnome.org)")
parser.add_argument('--recreate', action='store_true',
help="remove the project at GitLab if it exists and \
import the project from the original repository")
......@@ -449,24 +449,24 @@ def options():
required=True)
parser.add_argument('--bz-user', help="bugzilla username")
parser.add_argument('--bz-password', help="bugzilla password")
parser.add_argument('--target-product',
help="product name for gitlab, like 'username/product'. If not provided, \
$user_namespace/$product will be used")
parser.add_argument('--target-project', metavar="USERNAME/PROJECT",
help="project name for gitlab, like 'username/project'. If not provided, \
$user_namespace/$bugzilla_product will be used")
return parser.parse_args()
def check_if_target_project_exists(target):
try:
target.get_project()
except Exception as e:
print("ERROR: Could not access the project `{}` - are you sure it exists?".format(target.target_product))
print("You can use the --target-product=username/project option if the project name\n\
print("ERROR: Could not access the project `{}` - are you sure it exists?".format(target.target_project))
print("You can use the --target-project=username/project option if the project name\n\
is different from the Bugzilla product name.")
exit(1)
def main():
args = options()
target = GitLab(args.token, args.product, args.target_product,
target = GitLab(args.token, args.product, args.target_project,
args.automate)
if args.production:
target.GITLABURL = "https://gitlab.gnome.org/"
......@@ -475,7 +475,7 @@ def main():
check_if_target_project_exists(target)
if not args.target_product and args.recreate:
if not args.target_project and args.recreate:
target.import_project()
print("Connecting to bugzilla.gnome.org")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment