Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include real name in generated changelog entries #502

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions TarSCM/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,20 @@ def get_changesauthor(self, args):
return args.changesauthor

# return changesauthor if set by osc
if os.getenv('VC_MAILADDR'):
realname, mailaddr = os.getenv('VC_REALNAME'), os.getenv('VC_MAILADDR')
if mailaddr and realname:
logging.debug("Found VC_REALNAME='%s' and VC_MAILADDR='%s'",
realname, mailaddr)
return "%s <%s>" % (realname, mailaddr)

if mailaddr:
logging.debug("Found changesauthor in VC_MAILADDR='%s'",
os.environ['VC_MAILADDR'])
return os.environ['VC_MAILADDR']
mailaddr)
return mailaddr

# return default changesauthor if running on server side
if os.getenv('OBS_SERVICE_DAEMON'):
logging.debug("Running in daemon mode. Using DEFAULT_AUHTOR='%s'",
logging.debug("Running in daemon mode. Using DEFAULT_AUTHOR='%s'",
Cli.DEFAULT_AUTHOR)
return Cli.DEFAULT_AUTHOR

Expand Down
20 changes: 14 additions & 6 deletions tests/gitsvntests.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,22 @@ def _check_changes(self, orig_changes, expected_changes_regexp):

def test_changesgenerate_new_commit_and_changes_file(self): # pylint: disable=C0103
self._test_changesgenerate_new_commit_and_changes_file(
self.fixtures.user_email)
self.fixtures.user_email, self.fixtures.user_email)

def test_changesgenerate_new_commit_and_changes_file_default_author(self): # pylint: disable=C0103
os.environ['OBS_SERVICE_DAEMON'] = "1"
self._test_changesgenerate_new_commit_and_changes_file()
self._test_changesgenerate_new_commit_and_changes_file(None, 'obs-service-tar-scm@invalid')
os.environ['OBS_SERVICE_DAEMON'] = "0"

def test_changesgenerate_new_commit_and_changes_file_full_author(self): # pylint: disable=C0103
os.environ['OBS_SERVICE_DAEMON'] = "1"
os.environ['VC_REALNAME'] = 'Tar Scm Service'
os.environ['VC_MAILADDR'] = 'obs-service-tar-scm@invalid'
self._test_changesgenerate_new_commit_and_changes_file(None, 'Tar Scm Service <obs-service-tar-scm@invalid>')
os.environ['OBS_SERVICE_DAEMON'] = "0"
del os.environ['VC_REALNAME']
del os.environ['VC_MAILADDR']

def _write_servicedata(self, rev):
with open(os.path.join(self.pkgdir, '_servicedata'), 'w') as sdat:
sdat.write(textwrap.dedent("""\
Expand All @@ -129,16 +138,16 @@ def _write_servicedata(self, rev):
</service>
</servicedata>""" % (self.fixtures.repo_url, self.changesrevision(rev))))

def _test_changesgenerate_new_commit_and_changes_file(self, author=None): # pylint: disable=C0103
def _test_changesgenerate_new_commit_and_changes_file(self, changesauthor, expected_author): # pylint: disable=C0103
self._write_servicedata(2)
orig_changes = self._write_changes_file()
self.fixtures.create_commits(3)
rev = 5
print("XXXX 1")
tar_scm_args = self.tar_scm_args()

if author is not None:
tar_scm_args += ['--changesauthor', self.fixtures.user_email]
if changesauthor is not None:
tar_scm_args += ['--changesauthor', changesauthor]

print("XXXX 2")
self.tar_scm_std(*tar_scm_args)
Expand All @@ -149,7 +158,6 @@ def _test_changesgenerate_new_commit_and_changes_file(self, author=None): # pyl
rev = self.changesrevision(rev, abbrev=True)

print("XXXX 4")
expected_author = author or 'obs-service-tar-scm@invalid'
expected_changes_regexp = self._new_change_entry_regexp(
expected_author,
textwrap.dedent("""\
Expand Down
Loading