lftools github create-team no longer requires repo 70/62770/2
authorAric Gardner <agardner@linuxfoundation.org>
Thu, 9 Jan 2020 20:37:32 +0000 (15:37 -0500)
committerAric Gardner <agardner@linuxfoundation.org>
Thu, 9 Jan 2020 20:57:25 +0000 (15:57 -0500)
repo is now optional

ISSUE-ID: RELENG-2646
Signed-off-by: Aric Gardner <agardner@linuxfoundation.org>
Change-Id: I3cb31d17bb2fbe9e0ec7c419c99ad5cc2397d0f6

lftools/cli/github_cli.py
releasenotes/notes/github-create-team-52614d75e690f80d.yaml [new file with mode: 0644]

index 0b9e7b7..f8dbb2c 100644 (file)
@@ -214,8 +214,9 @@ def updaterepo(ctx, organization, repository, has_issues, has_projects, has_wiki
 @click.command(name='create-team')
 @click.argument('organization')
 @click.argument('name')
-@click.argument('repo')
 @click.argument('privacy')
+@click.option('--repo', type=str, required=False,
+              help='Assign team to repo')
 @click.pass_context
 def createteam(ctx, organization, name, repo, privacy):
     """Create a Github team within an Organization.
@@ -236,39 +237,50 @@ def createteam(ctx, organization, name, repo, privacy):
     except GithubException as ghe:
         print(ghe)
 
-    try:
-        repos = org.get_repos
-    except GithubException as ghe:
-        print(ghe)
+    if repo:
+        try:
+            repos = org.get_repos
+        except GithubException as ghe:
+            print(ghe)
+
+        my_repos = [repo]
+        repos = [repo for repo in repos() if repo.name in my_repos]
+        for repo in repos:
+            print(repo)
+        if repos:
+            print("repo found")
+        else:
+            print("repo not found")
+            sys.exit(1)
 
     try:
         teams = org.get_teams
     except GithubException as ghe:
         print(ghe)
 
-    my_repos = [repo]
-    repos = [repo for repo in repos() if repo.name in my_repos]
-    for repo in repos:
-        print(repo)
-
-    if repos:
-        print("repo found")
-    else:
-        print("repo not found")
-        sys.exit(1)
-
     for team in teams():
         if team.name == name:
             print("team {} already exists".format(team))
             sys.exit(1)
-    try:
-        org.create_team(
-            name=name,
-            repo_names=repos,
-            privacy=privacy
-        )
-    except GithubException as ghe:
-        print(ghe)
+
+    if repo:
+        try:
+            org.create_team(
+                name=name,
+                repo_names=repos,
+                privacy=privacy
+            )
+        except GithubException as ghe:
+            print(ghe)
+
+    if not repo:
+        try:
+            org.create_team(
+                name=name,
+                privacy=privacy
+            )
+        except GithubException as ghe:
+            print(ghe)
 
 
 @click.command(name='user')
diff --git a/releasenotes/notes/github-create-team-52614d75e690f80d.yaml b/releasenotes/notes/github-create-team-52614d75e690f80d.yaml
new file mode 100644 (file)
index 0000000..2abb151
--- /dev/null
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    lftools github create-team no longer requires repo
+    it is now an option