Update openstack-common log and setup code
Pull in changes up to commit 95cd3a7fad2d0335c65394379c35a798df9d25b4 Change-Id: I628f15aa6367ab2af7912f1b5324055a0fc3c20a
This commit is contained in:
parent
aaf36cbe29
commit
5c55801c1f
@ -54,15 +54,14 @@ log_opts = [
|
|||||||
'%(message)s',
|
'%(message)s',
|
||||||
help='format string to use for log messages with context'),
|
help='format string to use for log messages with context'),
|
||||||
cfg.StrOpt('logging_default_format_string',
|
cfg.StrOpt('logging_default_format_string',
|
||||||
default='%(asctime)s %(levelname)s %(name)s [-] %(instance)s'
|
default='%(asctime)s %(process)d %(levelname)s %(name)s [-]'
|
||||||
'%(message)s',
|
' %(instance)s%(message)s',
|
||||||
help='format string to use for log messages without context'),
|
help='format string to use for log messages without context'),
|
||||||
cfg.StrOpt('logging_debug_format_suffix',
|
cfg.StrOpt('logging_debug_format_suffix',
|
||||||
default='from (pid=%(process)d) %(funcName)s '
|
default='%(funcName)s %(pathname)s:%(lineno)d',
|
||||||
'%(pathname)s:%(lineno)d',
|
|
||||||
help='data to append to log format when level is DEBUG'),
|
help='data to append to log format when level is DEBUG'),
|
||||||
cfg.StrOpt('logging_exception_prefix',
|
cfg.StrOpt('logging_exception_prefix',
|
||||||
default='%(asctime)s TRACE %(name)s %(instance)s',
|
default='%(asctime)s %(process)d TRACE %(name)s %(instance)s',
|
||||||
help='prefix each line of exception output with this format'),
|
help='prefix each line of exception output with this format'),
|
||||||
cfg.ListOpt('default_log_levels',
|
cfg.ListOpt('default_log_levels',
|
||||||
default=[
|
default=[
|
||||||
|
@ -52,7 +52,6 @@ def canonicalize_emails(changelog, mapping):
|
|||||||
|
|
||||||
# Get requirements from the first file that exists
|
# Get requirements from the first file that exists
|
||||||
def get_reqs_from_files(requirements_files):
|
def get_reqs_from_files(requirements_files):
|
||||||
reqs_in = []
|
|
||||||
for requirements_file in requirements_files:
|
for requirements_file in requirements_files:
|
||||||
if os.path.exists(requirements_file):
|
if os.path.exists(requirements_file):
|
||||||
return open(requirements_file, 'r').read().split('\n')
|
return open(requirements_file, 'r').read().split('\n')
|
||||||
@ -127,13 +126,6 @@ def _run_shell_command(cmd):
|
|||||||
return out[0].strip()
|
return out[0].strip()
|
||||||
|
|
||||||
|
|
||||||
def _get_git_branch_name():
|
|
||||||
branch_ref = _run_shell_command("git symbolic-ref -q HEAD")
|
|
||||||
if branch_ref is None:
|
|
||||||
return "HEAD"
|
|
||||||
return branch_ref[len("refs/heads/"):]
|
|
||||||
|
|
||||||
|
|
||||||
def _get_git_next_version_suffix(branch_name):
|
def _get_git_next_version_suffix(branch_name):
|
||||||
datestamp = datetime.datetime.now().strftime('%Y%m%d')
|
datestamp = datetime.datetime.now().strftime('%Y%m%d')
|
||||||
if branch_name == 'milestone-proposed':
|
if branch_name == 'milestone-proposed':
|
||||||
@ -144,15 +136,15 @@ def _get_git_next_version_suffix(branch_name):
|
|||||||
milestone_cmd = "git show meta/openstack/release:%s" % branch_name
|
milestone_cmd = "git show meta/openstack/release:%s" % branch_name
|
||||||
milestonever = _run_shell_command(milestone_cmd)
|
milestonever = _run_shell_command(milestone_cmd)
|
||||||
if not milestonever:
|
if not milestonever:
|
||||||
milestonever = branch_name
|
milestonever = ""
|
||||||
post_version = _get_git_post_version()
|
post_version = _get_git_post_version()
|
||||||
# post version should look like:
|
# post version should look like:
|
||||||
# 0.1.1.4.cc9e28a
|
# 0.1.1.4.gcc9e28a
|
||||||
# where the bit after the last . is the short sha, and the bit between
|
# where the bit after the last . is the short sha, and the bit between
|
||||||
# the last and second to last is the revno count
|
# the last and second to last is the revno count
|
||||||
(revno, sha) = post_version.split(".")[-2:]
|
(revno, sha) = post_version.split(".")[-2:]
|
||||||
first_half = "%(milestonever)s~%(datestamp)s" % locals()
|
first_half = "%s~%s" % (milestonever, datestamp)
|
||||||
second_half = "%(revno_prefix)s%(revno)s.%(sha)s" % locals()
|
second_half = "%s%s.%s" % (revno_prefix, revno, sha)
|
||||||
return ".".join((first_half, second_half))
|
return ".".join((first_half, second_half))
|
||||||
|
|
||||||
|
|
||||||
@ -180,19 +172,21 @@ def _get_git_post_version():
|
|||||||
tag_infos = tag_info.split("-")
|
tag_infos = tag_info.split("-")
|
||||||
base_version = "-".join(tag_infos[:-2])
|
base_version = "-".join(tag_infos[:-2])
|
||||||
(revno, sha) = tag_infos[-2:]
|
(revno, sha) = tag_infos[-2:]
|
||||||
# git describe prefixes the sha with a g
|
|
||||||
sha = sha[1:]
|
|
||||||
return "%s.%s.%s" % (base_version, revno, sha)
|
return "%s.%s.%s" % (base_version, revno, sha)
|
||||||
|
|
||||||
|
|
||||||
def write_git_changelog():
|
def write_git_changelog():
|
||||||
"""Write a changelog based on the git changelog."""
|
"""Write a changelog based on the git changelog."""
|
||||||
if os.path.isdir('.git'):
|
new_changelog = 'ChangeLog'
|
||||||
git_log_cmd = 'git log --stat'
|
if not os.getenv('SKIP_WRITE_GIT_CHANGELOG'):
|
||||||
changelog = _run_shell_command(git_log_cmd)
|
if os.path.isdir('.git'):
|
||||||
mailmap = parse_mailmap()
|
git_log_cmd = 'git log --stat'
|
||||||
with open("ChangeLog", "w") as changelog_file:
|
changelog = _run_shell_command(git_log_cmd)
|
||||||
changelog_file.write(canonicalize_emails(changelog, mailmap))
|
mailmap = parse_mailmap()
|
||||||
|
with open(new_changelog, "w") as changelog_file:
|
||||||
|
changelog_file.write(canonicalize_emails(changelog, mailmap))
|
||||||
|
else:
|
||||||
|
open(new_changelog, 'w').close()
|
||||||
|
|
||||||
|
|
||||||
def generate_authors():
|
def generate_authors():
|
||||||
@ -200,17 +194,21 @@ def generate_authors():
|
|||||||
jenkins_email = 'jenkins@review.openstack.org'
|
jenkins_email = 'jenkins@review.openstack.org'
|
||||||
old_authors = 'AUTHORS.in'
|
old_authors = 'AUTHORS.in'
|
||||||
new_authors = 'AUTHORS'
|
new_authors = 'AUTHORS'
|
||||||
if os.path.isdir('.git'):
|
if not os.getenv('SKIP_GENERATE_AUTHORS'):
|
||||||
# don't include jenkins email address in AUTHORS file
|
if os.path.isdir('.git'):
|
||||||
git_log_cmd = ("git log --format='%aN <%aE>' | sort -u | "
|
# don't include jenkins email address in AUTHORS file
|
||||||
"grep -v " + jenkins_email)
|
git_log_cmd = ("git log --format='%aN <%aE>' | sort -u | "
|
||||||
changelog = _run_shell_command(git_log_cmd)
|
"grep -v " + jenkins_email)
|
||||||
mailmap = parse_mailmap()
|
changelog = _run_shell_command(git_log_cmd)
|
||||||
with open(new_authors, 'w') as new_authors_fh:
|
mailmap = parse_mailmap()
|
||||||
new_authors_fh.write(canonicalize_emails(changelog, mailmap))
|
with open(new_authors, 'w') as new_authors_fh:
|
||||||
if os.path.exists(old_authors):
|
new_authors_fh.write(canonicalize_emails(changelog, mailmap))
|
||||||
with open(old_authors, "r") as old_authors_fh:
|
if os.path.exists(old_authors):
|
||||||
new_authors_fh.write('\n' + old_authors_fh.read())
|
with open(old_authors, "r") as old_authors_fh:
|
||||||
|
new_authors_fh.write('\n' + old_authors_fh.read())
|
||||||
|
else:
|
||||||
|
open(new_authors, 'w').close()
|
||||||
|
|
||||||
|
|
||||||
_rst_template = """%(heading)s
|
_rst_template = """%(heading)s
|
||||||
%(underline)s
|
%(underline)s
|
||||||
@ -319,6 +317,15 @@ def get_cmdclass():
|
|||||||
return cmdclass
|
return cmdclass
|
||||||
|
|
||||||
|
|
||||||
|
def get_git_branchname():
|
||||||
|
for branch in _run_shell_command("git branch --color=never").split("\n"):
|
||||||
|
if branch.startswith('*'):
|
||||||
|
_branch_name = branch.split()[1].strip()
|
||||||
|
if _branch_name == "(no":
|
||||||
|
_branch_name = "no-branch"
|
||||||
|
return _branch_name
|
||||||
|
|
||||||
|
|
||||||
def get_pre_version(projectname, base_version):
|
def get_pre_version(projectname, base_version):
|
||||||
"""Return a version which is leading up to a version that will
|
"""Return a version which is leading up to a version that will
|
||||||
be released in the future."""
|
be released in the future."""
|
||||||
@ -329,7 +336,7 @@ def get_pre_version(projectname, base_version):
|
|||||||
else:
|
else:
|
||||||
branch_name = os.getenv('BRANCHNAME',
|
branch_name = os.getenv('BRANCHNAME',
|
||||||
os.getenv('GERRIT_REFNAME',
|
os.getenv('GERRIT_REFNAME',
|
||||||
_get_git_branch_name()))
|
get_git_branchname()))
|
||||||
version_suffix = _get_git_next_version_suffix(branch_name)
|
version_suffix = _get_git_next_version_suffix(branch_name)
|
||||||
version = "%s~%s" % (base_version, version_suffix)
|
version = "%s~%s" % (base_version, version_suffix)
|
||||||
write_versioninfo(projectname, version)
|
write_versioninfo(projectname, version)
|
||||||
|
Loading…
Reference in New Issue
Block a user