From 0c6abf6fea8d9cdf5834f40cf5dc51602d2c1cab Mon Sep 17 00:00:00 2001
From: James Tanner <tanner.jc@gmail.com>
Date: Tue, 31 Oct 2023 08:09:32 -0400
Subject: [PATCH] github_repo should set repository.name

Signed-off-by: James Tanner <tanner.jc@gmail.com>
---
 galaxy_ng/app/api/v1/viewsets/roles.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/galaxy_ng/app/api/v1/viewsets/roles.py b/galaxy_ng/app/api/v1/viewsets/roles.py
index d339c2d193..ebf227a9e1 100644
--- a/galaxy_ng/app/api/v1/viewsets/roles.py
+++ b/galaxy_ng/app/api/v1/viewsets/roles.py
@@ -111,7 +111,6 @@ def update(self, request, pk=None):
                     changed['repository'] = {}
                     role.full_metadata['repository'] = {}
                 for subkey, subval in newval.items():
-                    print(f'{key}.{subkey} {role.full_metadata[key].get(subkey)} --> {subval}')
                     if role.full_metadata.get(key, {}).get(subkey) != subval:
                         if key not in changed:
                             changed[key] = {}
@@ -119,6 +118,15 @@ def update(self, request, pk=None):
                         changed[key][subkey] = subval
                 continue
 
+            # github_repo should set repository.name?
+            if key == 'github_repo':
+                if not role.full_metadata.get('repository'):
+                    changed['repository'] = {}
+                    role.full_metadata['repository'] = {}
+                old_name = role.full_metadata['repository'].get('name')
+                role.full_metadata['repository']['name'] = newval
+                role.full_metadata['repository']['original_name'] = old_name
+
             if role.full_metadata.get(key) != newval:
                 role.full_metadata[key] = newval
                 changed[key] = newval