From a54e97156085d873ffe9761ef3afa557fd646b29 Mon Sep 17 00:00:00 2001
From: Mohan Boddu <mboddu@bhujji.com>
Date: Feb 24 2021 17:27:06 +0000
Subject: [PATCH 1/2] Changes for default branches on different namespaces


Fix for #428

Signed-off-by: Mohan Boddu <mboddu@bhujji.com>

---

diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py
index 2ec2d6e..155b6d7 100644
--- a/fedpkg/__init__.py
+++ b/fedpkg/__init__.py
@@ -169,7 +169,7 @@ class Commands(pyrpkg.Commands):
                 "--define 'rhel %s'" % macros['rhel'],
             ]
         # rawhide (previously master branch)
-        elif re.match(r'(master|rawhide|main)$', self.branch_merge):
+        elif re.match(r'(rawhide|main)$', self.branch_merge):
             self._distval = self._findrawhidebranch()
             self._distvar = 'fedora'
             self._disttag = 'fc%s' % self._distval
@@ -204,13 +204,13 @@ class Commands(pyrpkg.Commands):
             self._rpmdefines.extend(extra_rpmdefines)
 
     def build_target(self, release):
-        if release in ('rawhide', 'main', 'master'):
+        if release in ('rawhide', 'main'):
             return 'rawhide'
         else:
             return '%s-candidate' % release
 
     def load_container_build_target(self):
-        if self.branch_merge in ('rawhide', 'main', 'master'):
+        if self.branch_merge in ('rawhide', 'main'):
             self._container_build_target = 'rawhide-%s-candidate' % self.ns
         else:
             super(Commands, self).load_container_build_target()
diff --git a/fedpkg/cli.py b/fedpkg/cli.py
index 1d790ee..b23634c 100644
--- a/fedpkg/cli.py
+++ b/fedpkg/cli.py
@@ -814,11 +814,18 @@ class fedpkgClient(cliClient):
             self.log.info('Bodhi update aborted!')
 
     def request_repo(self):
+        ns = self.args.new_repo_namespace
+        if ns in ['rpms', 'container', 'modules']:
+            branch = 'rawhide'
+        elif ns == 'flatpaks':
+            branch = 'stable'
+        elif ns == 'tests':
+            branch = 'main'
         self._request_repo(
             logger=self.log,
             repo_name=self.args.name,
-            ns=self.args.new_repo_namespace,
-            branch='rawhide',
+            ns=ns,
+            branch=branch,
             summary=self.args.summary,
             description=self.args.description,
             upstreamurl=self.args.upstreamurl,
@@ -912,7 +919,7 @@ class fedpkgClient(cliClient):
 
             ticket_body = {
                 'action': 'new_repo',
-                'branch': 'rawhide',
+                'branch': 'main',
                 'bug_id': bug or '',
                 'monitor': 'no-monitoring',
                 'namespace': 'tests',
diff --git a/fedpkg/utils.py b/fedpkg/utils.py
index 6bf3d0a..046ead3 100644
--- a/fedpkg/utils.py
+++ b/fedpkg/utils.py
@@ -436,7 +436,7 @@ def get_stream_branches(server_url, package_name):
     # should be ok to remove if from this list.
     stream_branches = []
     for item in branches:
-        if item['name'] in ('master', 'rawhide', 'main'):
+        if item['name'] in ('rawhide', 'main'):
             continue
         elif re.match(r'^(f|el)\d+$', item['name']):
             continue
@@ -469,7 +469,7 @@ def expand_release(rel, active_releases):
         returned from `get_release_branches`.
     :return: list of releases, for example ``[f28]``, or ``[el6, epel7]``.
     """
-    if rel in ('master', 'rawhide', 'main'):
+    if rel in ('rawhide', 'main'):
         return ['rawhide']
     elif rel == 'fedora':
         return active_releases['fedora']

From d7dc557c95cad3f8e5d53eef1b323795d6bf0370 Mon Sep 17 00:00:00 2001
From: Mohan Boddu <mboddu@bhujji.com>
Date: Feb 24 2021 22:07:37 +0000
Subject: [PATCH 2/2] Cleaner approach of default branch in new repo request


Signed-off-by: Mohan Boddu <mboddu@bhujji.com>

---

diff --git a/fedpkg/cli.py b/fedpkg/cli.py
index b23634c..406151f 100644
--- a/fedpkg/cli.py
+++ b/fedpkg/cli.py
@@ -814,18 +814,11 @@ class fedpkgClient(cliClient):
             self.log.info('Bodhi update aborted!')
 
     def request_repo(self):
-        ns = self.args.new_repo_namespace
-        if ns in ['rpms', 'container', 'modules']:
-            branch = 'rawhide'
-        elif ns == 'flatpaks':
-            branch = 'stable'
-        elif ns == 'tests':
-            branch = 'main'
         self._request_repo(
             logger=self.log,
             repo_name=self.args.name,
-            ns=ns,
-            branch=branch,
+            ns=self.args.new_repo_namespace,
+            branch='rawhide',
             summary=self.args.summary,
             description=self.args.description,
             upstreamurl=self.args.upstreamurl,
@@ -927,6 +920,9 @@ class fedpkgClient(cliClient):
                 'description': description,
             }
         else:
+            # Default branch is rawhide, but for flatpaks namespace its 'stable'
+            if ns == 'flatpaks':
+                branch = 'stable'
             ticket_body = {
                 'action': 'new_repo',
                 'branch': branch,

