mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Consider the current project git config when releasing to DistGit
I use two different email addresses for git config, depending on what kind of project it is going on. I use my personal email address for public community projects and my work email address for internal repositories. Let's say my global config is my personal address $ git config --get --global user.email frostyx@email.cz And that I am working on an internal project, therefore I set git config user.email "jkadlcik@redhat.com" Once I run `tito release internal`, I would like all changes to be commited with my work address, i.e. I would like the local git user config to be considered. This commit fixes that.
This commit is contained in:
parent
0df894d613
commit
bd7b56a93a
3 changed files with 43 additions and 18 deletions
|
@ -899,6 +899,25 @@ def get_git_repo_url():
|
|||
return run_command("git config remote.origin.url")
|
||||
|
||||
|
||||
def get_git_user_info():
|
||||
"""
|
||||
Return the `user.name` and `user.email` git config values.
|
||||
The `--global` parameter is not specified and therefore the returned values
|
||||
are current-working-directory specific.
|
||||
"""
|
||||
try:
|
||||
name = run_command('git config --get user.name')
|
||||
except:
|
||||
warn_out('user.name in ~/.gitconfig not set.\n')
|
||||
name = 'Unknown name'
|
||||
try:
|
||||
email = run_command('git config --get user.email')
|
||||
except:
|
||||
warn_out('user.email in ~/.gitconfig not set.\n')
|
||||
email = None
|
||||
return (name, email)
|
||||
|
||||
|
||||
def get_latest_tagged_version(package_name):
|
||||
"""
|
||||
Return the latest git tag for this package in the current branch.
|
||||
|
|
|
@ -16,8 +16,17 @@ import subprocess
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
from tito.common import run_command, debug, extract_sources, \
|
||||
error_out, chdir, warn_out, info_out, find_mead_chain_file
|
||||
from tito.common import (
|
||||
run_command,
|
||||
debug,
|
||||
extract_sources,
|
||||
error_out,
|
||||
chdir,
|
||||
warn_out,
|
||||
info_out,
|
||||
find_mead_chain_file,
|
||||
get_git_user_info,
|
||||
)
|
||||
from tito.compat import getoutput, getstatusoutput, write
|
||||
from tito.release import Releaser
|
||||
from tito.release.main import PROTECTED_BUILD_SYS_FILES
|
||||
|
@ -90,6 +99,9 @@ class FedoraGitReleaser(Releaser):
|
|||
with chdir(self.package_workdir):
|
||||
run_command("%s switch-branch %s" % (self.cli_tool, self.git_branches[0]))
|
||||
|
||||
# Set git user config to the distgit clone based on the current project
|
||||
self._git_set_user_config()
|
||||
|
||||
# Mead builds need to be in the git_root. Other builders are agnostic.
|
||||
with chdir(self.git_root):
|
||||
self.builder.tgz()
|
||||
|
@ -102,6 +114,13 @@ class FedoraGitReleaser(Releaser):
|
|||
self._git_upload_sources(self.package_workdir)
|
||||
self._git_user_confirm_commit(self.package_workdir)
|
||||
|
||||
def _git_set_user_config(self):
|
||||
fullname, email = get_git_user_info()
|
||||
email = email or ""
|
||||
with chdir(self.package_workdir):
|
||||
run_command("git config user.name '{0}'".format(fullname))
|
||||
run_command("git config user.email '{0}'".format(email))
|
||||
|
||||
def _get_bz_flags(self):
|
||||
required_bz_flags = None
|
||||
if self.releaser_config.has_option(self.target,
|
||||
|
|
|
@ -37,7 +37,8 @@ from tito.common import (debug, error_out, run_command,
|
|||
get_spec_version_and_release, replace_version,
|
||||
tag_exists_locally, tag_exists_remotely, head_points_to_tag, undo_tag,
|
||||
increase_version, reset_release, increase_zstream, warn_out,
|
||||
BUILDCONFIG_SECTION, get_relative_project_dir_cwd, info_out)
|
||||
BUILDCONFIG_SECTION, get_relative_project_dir_cwd, info_out,
|
||||
get_git_user_info)
|
||||
from tito.compat import write, StringIO, getstatusoutput
|
||||
from tito.exception import TitoException
|
||||
from tito.config_object import ConfigObject
|
||||
|
@ -69,7 +70,7 @@ class VersionTagger(ConfigObject):
|
|||
self.keep_version = keep_version
|
||||
|
||||
self.today = self._changelog_date()
|
||||
(self.git_user, self.git_email) = self._get_git_user_info()
|
||||
(self.git_user, self.git_email) = get_git_user_info()
|
||||
git_email = self.git_email
|
||||
if git_email is None:
|
||||
git_email = ''
|
||||
|
@ -546,20 +547,6 @@ class VersionTagger(ConfigObject):
|
|||
print("Assuming package has been renamed and removing it.")
|
||||
run_command("git rm %s" % metadata_file)
|
||||
|
||||
def _get_git_user_info(self):
|
||||
""" Return the user.name and user.email git config values. """
|
||||
try:
|
||||
name = run_command('git config --get user.name')
|
||||
except:
|
||||
warn_out('user.name in ~/.gitconfig not set.\n')
|
||||
name = 'Unknown name'
|
||||
try:
|
||||
email = run_command('git config --get user.email')
|
||||
except:
|
||||
warn_out('user.email in ~/.gitconfig not set.\n')
|
||||
email = None
|
||||
return (name, email)
|
||||
|
||||
def _get_new_tag(self, version_and_release):
|
||||
""" Returns the actual tag we'll be creating. """
|
||||
suffixed_version = self._get_suffixed_version(self._get_version(version_and_release))
|
||||
|
|
Loading…
Add table
Reference in a new issue