Hello community, here is the log from the commit of package yast2-devtools for openSUSE:Factory checked in at 2020-05-09 19:49:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-devtools (Old) and /work/SRC/openSUSE:Factory/.yast2-devtools.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-devtools" Sat May 9 19:49:57 2020 rev:99 rq:800787 version:4.2.6 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-devtools/yast2-devtools.changes 2019-07-31 14:23:35.590423516 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-devtools.new.2738/yast2-devtools.changes 2020-05-09 19:50:24.072586308 +0200 @@ -1,0 +2,7 @@ +Tue May 5 13:20:44 UTC 2020 - Stefan Hundhammer <[email protected]> + +- New script to add format hints for translated messages: + po_add_format_hints (bsc#954505, bsc#980329) +- 4.2.6 + +------------------------------------------------------------------- Old: ---- yast2-devtools-4.2.5.tar.bz2 New: ---- yast2-devtools-4.2.6.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-devtools.spec ++++++ --- /var/tmp/diff_new_pack.SKpMU0/_old 2020-05-09 19:50:26.624591786 +0200 +++ /var/tmp/diff_new_pack.SKpMU0/_new 2020-05-09 19:50:26.628591795 +0200 @@ -1,7 +1,7 @@ # # spec file for package yast2-devtools # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: yast2-devtools -Version: 4.2.5 +Version: 4.2.6 Release: 0 Url: https://github.com/yast/yast-devtools Summary: YaST2 - Development Tools @@ -137,6 +137,7 @@ %{_datadir}/YaST2/data/devtools/bin/showy2log %{_datadir}/YaST2/data/devtools/bin/tagversion %{_datadir}/YaST2/data/devtools/bin/y2makepot +%{_datadir}/YaST2/data/devtools/bin/po_add_format_hints %{_datadir}/YaST2/data/devtools/bin/gettextdomains %{_datadir}/YaST2/data/devtools/bin/ycp_puttext %{_datadir}/YaST2/data/devtools/data/rubocop_yast_style.yml ++++++ yast2-devtools-4.2.5.tar.bz2 -> yast2-devtools-4.2.6.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/.travis.yml new/yast2-devtools-4.2.6/.travis.yml --- old/yast2-devtools-4.2.5/.travis.yml 2019-07-17 10:09:26.000000000 +0200 +++ new/yast2-devtools-4.2.6/.travis.yml 2020-05-06 17:19:20.000000000 +0200 @@ -8,4 +8,4 @@ script: # the "yast-travis-cpp" script is included in the base yastdevel/cpp image # see https://github.com/yast/docker-yast-cpp/blob/master/yast-travis-cpp - - docker run -it yast-devtools-image yast-travis-cpp + - docker run -it --privileged yast-devtools-image yast-travis-cpp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/CONTRIBUTING.md new/yast2-devtools-4.2.6/CONTRIBUTING.md --- old/yast2-devtools-4.2.5/CONTRIBUTING.md 2019-07-17 10:09:26.000000000 +0200 +++ new/yast2-devtools-4.2.6/CONTRIBUTING.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,89 +0,0 @@ -YaST Contribution Guidelines -============================ - -YaST is an open source project and as such it welcomes all kinds of -contributions. If you decide to contribute, please follow these guidelines to -ensure the process is effective and pleasant both for you and the YaST maintainers. - -There are two main forms of contribution: reporting bugs and performing code -changes. - -Bug Reports ------------ - -If you find a problem, please report it either using -[Bugzilla](https://bugzilla.suse.com/enter_bug.cgi?format=guided&product=openSUSE+Factory&component=YaST2) -or [GitHub issues](../../issues). (For Bugzilla, use the [simplified -registration](https://secure-www.novell.com/selfreg/jsp/createSimpleAccount.jsp) -if you don't have an account yet.) - -When creating a bug report, please follow our [bug reporting -guidelines](http://en.opensuse.org/openSUSE:Report_a_YaST_bug). - -We can't guarantee that every bug will be fixed, but we'll try. - -Code Changes ------------- - -We welcome all kinds of code contributions, from simple bug fixes to significant -refactorings and implementation of new features. However, before making any -non-trivial contribution, get in touch with us first — this can prevent wasted -effort on both sides. Also, have a look at our [development -documentation](http://en.opensuse.org/openSUSE:YaST_development). - -To send us your code change, use GitHub pull requests. The workflow is as -follows: - - 1. Fork the project. - - 2. Create a topic branch based on `master`. - - 3. Implement your change, including tests (if possible). Make sure you adhere - to the [Ruby style - guide](https://github.com/SUSE/style-guides/blob/master/Ruby.md). - - 4. Update the package version (in `packages/*.spec`, usually by - `rake version:bump`) and add a new entry to the `package/*.changes` file - (by `osc vc package`). - For bigger changes or changes which need longer discussion it is advised to - add this as a separate last commit so it can be easily updated when another - change is merged in the meantime. - - 5. Make sure your change didn't break anything by building the RPM package - (`rake osc:build`). The build process includes running the full testsuite. - - 6. Publish the branch and create a pull request. - - 7. YaST developers will review your change and possibly point out issues. - Adapt the code under their guidance until they are all resolved. - - 8. Finally, the pull request will get merged or rejected. - -See also [GitHub's guide on -contributing](https://help.github.com/articles/fork-a-repo). - -If you want to do multiple unrelated changes, use separate branches and pull -requests. - -### Commits - -Each commit in the pull request should do only one thing, which is clearly -described by its commit message. Especially avoid mixing formatting changes and -functional changes into one commit. When writing commit messages, adhere to -[widely used -conventions](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). - -If your commit is related to a bug in Bugzilla or an issue on GitHub, make sure -you mention it in the commit message for cross-reference. Use format like -bnc#775814 or gh#yast/yast-foo#42. See also [GitHub -autolinking](https://help.github.com/articles/github-flavored-markdown#references) -and [openSUSE abbreviation -reference](http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines#Current_set_of_abbreviations). - -Additional Information ----------------------- - -If you have any question, feel free to ask at the [development mailing -list](http://lists.opensuse.org/yast-devel/) or at the -[#yast](http://webchat.freenode.net/?channels=%23yast) IRC channel on freenode. -We'll do our best to provide a timely and accurate answer. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/build-tools/scripts/Makefile.am new/yast2-devtools-4.2.6/build-tools/scripts/Makefile.am --- old/yast2-devtools-4.2.5/build-tools/scripts/Makefile.am 2019-07-17 10:09:26.000000000 +0200 +++ new/yast2-devtools-4.2.6/build-tools/scripts/Makefile.am 2020-05-06 17:19:20.000000000 +0200 @@ -9,7 +9,8 @@ y2autoconf \ y2automake \ y2makepot \ - y2metainfo + y2metainfo \ + po_add_format_hints # This file should have 0644 perms, since it gets # sourced by 'check-textdomain' and 'y2makepot'. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/build-tools/scripts/po_add_format_hints new/yast2-devtools-4.2.6/build-tools/scripts/po_add_format_hints --- old/yast2-devtools-4.2.5/build-tools/scripts/po_add_format_hints 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-devtools-4.2.6/build-tools/scripts/po_add_format_hints 2020-05-06 17:19:20.000000000 +0200 @@ -0,0 +1,304 @@ +#!/usr/bin/env ruby +# +# encoding: utf-8 + +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +# +# --------------------------------------------------------------------------- +# +# This script will add format marker hints to .po and .pot files: +# +# %s %d etc. -> c-format +# %1 %2 etc. -> ycp-format +# %{foo} %{bar} -> perl-brace-format +# +# msgfmt and msgmerge understand those formats and will check if a translation +# has the same placeholders as the untranslated message. +# +# This script is usually called from y2makepot (which is called via "rake pot") +# after creating a .pot file from Ruby source code with "rxgettext" (from +# package rubygem-gettext). It uses the same .po parser as "rxgettext". +# +# Usage: +# +# po_add_format_hints [OPTIONS] mymessages.pot [mymessages2.pot] +# +# Options: +# +# -n, --dry-run : Dry run; don't modify the file +# -v, --verbose : More output +# -s, --silent : No output +# -p, --no-perl-brace-format : Don't use the perl-brace-format +# +# It is NOT necessary to call this for each .po file for each language as well: +# The "msgmerge" command will do that while it merges new or changed messages +# from the .pot file into each .po file for each language. +# +# Use a standard xgettext comment to override this script: +# +# # xgettext:c-format +# foo(_"... %1 ...") +# +# Author: Stefan Hundhammer <[email protected]> +# + +require "optparse" +require "gettext" +require "gettext/po_parser" +require "gettext/po" + +module Yast + module GetText + module Tools + # Class to add format marker hints to .po and .pot files + class PoAddFormatHints + SHORT_MSG_LIMIT = 50 + attr_accessor :dry_run, :verbose, :silent, :perl_brace_format + attr_reader :current_file_modifications, :total_modifications + + # Constructor + def initialize + @dry_run = false + @verbose = false + @silent = false + @perl_brace_format = true + @current_file_modifications = 0 + @total_modifications = 0 + @po_format_options = + { + :max_line_width => ::GetText::POEntry::Formatter::DEFAULT_MAX_LINE_WIDTH + } + @po_parser = nil + end + + # Normal entry point if used as a standalone command. + def run(command_line_args) + po_files = parse_command_line(command_line_args) + po_files.each { |po_file| add_format_hints(po_file) } + if po_files.size > 1 && !@silent + puts("Total: #{@total_modifications} format flags added") + end + end + + # Read and parse a .po or .pot file named 'po_file', check each entry + # for format strings and add format flags accordingly. If there was any + # modification and this is not a dry run, write the result back to the + # same file. + def add_format_hints(po_file) + po = read_po(po_file) + log_verbose("Parsing #{po_file} (#{po.entries.size} entries)") + detect_formats(po) + if @current_file_modifications > 0 && !@silent + puts("#{po_file}: #{@current_file_modifications} format flags added") + end + write_po(po_file, po) unless @dry_run + po + end + + # Read a file named 'po_file' and return the corresponding PO object. + def read_po(po_file) + po = ::GetText::PO.new + po_parser.parse_file(po_file, po) + @current_file_modifications = 0 + po + end + + # Write a PO object 'po' to a file named 'po_file' unless there was no + # modification. This returns 'true' if okay, 'false' if error. + def write_po(po_file, po, force = false) + if current_file_unmodified? && !force + log_verbose("Not modified: #{po_file}") + return true + end + po_string = po.to_s(@po_format_options) + if po_string.empty? + warn("#{$0}: No output for #{po_file}") + return false + end + log_verbose("Writing #{po_file}") + File.write(po_file, po_string) + true + end + + # Detect the formats in all messages in PO object 'po' and add them to + # the flags of each entry. Leave entries alone that already have a + # format flag (typically set by a commend starting with "xgettext:" in + # the source file). + def detect_formats(po) + po.each do |entry| + next if entry.msgid.empty? + msg = entry.msgid.chomp + if has_format_flag?(entry) + log_indented("Skipping existing format: \"#{short_msg(msg)}\"") + next + end + # log_verbose("Checking \"#{short_msg(msg)}\"") + format = find_known_formats(msg) + if format + log_verbose("* Adding #{format} to \"#{short_msg(msg)}\"") + entry.flags << format + @current_file_modifications += 1 + @total_modifications += 1 + end + end + end + + # Check if a PO entry already has a format flag + # ("c-format", "ycp-format", ...). + def has_format_flag?(po_entry) + po_entry.flags.any? { |flag| flag.end_with?("-format") } + end + + # Check if a message contains any of the known formats. + # + # If yes, return that format as a string ("c-format", "ycp-format"). + # If no, return 'nil'. + def find_known_formats(msg) + case remove_escaped_percent(msg) + when /%[sdixXoeEfgGbB]/ # simple printf-like %s %d %x ... + log_indented("Detected simple printf()-like format") + "c-format" + when /%[0-9]*\$[sdixXoeEfgGbB]/ + log_indented("Detected positional parameters in printf()-like format") + "c-format" + when /%[-+ ]?[0-9]+[sdixXoeEfgGbB]/, /%[-+ ]?[0-9]+\.[0-9]+[sdixXoeEfgGbB]/ + # More elaborate printf-like formats. + # Notice this does not catch all weird cases, but a translator + # should not confronted with this anyway; this should be formatted + # into a string first and THEN put into a message that the + # translator sees. + log_indented("Detected complex printf()-like format") + "c-format" + when /%[1-9]/ # sformat-like %1 %2 %3 ... + log_indented("Detected sformat()-like positional parameters") + "ycp-format" + when /%{[a-zA-Z_][a-zA-Z0-9_]*}/ # Named parameters %{foo} %{bar} + if @perl_brace_format + log_indented("Detected named parameters %{value}") + "perl-brace-format" + else + log_indented("Detected named parameters %{value} (ignored as requested)") + nil + end + when /%<[a-zA-Z_][a-zA-Z0-9_]*>/ # Named parameters %{foo} %{bar} + log_indented("Detected named parameters %<value> (no suitable xgettext format flag)") + nil + else + nil + end + end + + # Return the po parser; create it if it doesn't exist yet. + def po_parser + @po_parser ||= create_po_parser + end + + # Parse the command line and modify internal flags accordingly. + # Return the non-option command line arguments: The .po files to work on. + def parse_command_line(command_line_args) + parser = create_option_parser + po_files = parser.parse(command_line_args) + # Unfortunately, there is no better documented way to show the usage + # and terminate the program if no other command line arguments were given. + parser.parse("-h") if po_files.empty? + po_files + end + + private + + def create_option_parser + parser = OptionParser.new + # parser.version = "1.0" + parser.banner = ("Usage: %s [OPTIONS] PO_FILE1 [PO_FILE2] ...") % File.basename($0) + parser.separator("") + parser.separator("Add PO format marker hints to .pot and .po files:") + parser.separator(" \"%s %d\" etc. -> c-format") + parser.separator(" \"%1 %2\" etc. -> ycp-format") + parser.separator(" \"%{foo} %{bar}\" etc. -> perl-brace-format") + parser.separator("") + parser.separator("The markers are added in-place unless the --dry-run option is given.") + parser.separator("") + parser.separator("Use the usual xgettext comments to override this:") + parser.separator(" # xgettext:c-format") + parser.separator(" foo(_(\"... %1 ...\"))") + parser.separator("") + parser.separator("Options:") + + parser.on("-n", "--dry-run", "Dry run; don't modify the file") do |dry_run| + @dry_run = dry_run + end + + parser.on("-p", "--no-perl-brace-format", "Don't use the perl-brace-format") do |p| + @perl_brace_format = false + end + + parser.on("-v", "--verbose", "More output") do |verbose| + @verbose = verbose + end + + parser.on("-s", "--silent", "No output") do |silent| + @silent = silent + end + + parser + end + + def create_po_parser + po_parser ||= ::GetText::POParser.new + po_parser.report_warning = true + po_parser + end + + # Write a message to stdout if the --verbose command line option was set + def log_verbose(msg) + puts(msg) if @verbose + end + + # Write a message to stdout if --verbose is set with indentation. + def log_indented(msg) + log_verbose(" " + msg) + end + + # Return a message suitable for debug output: + # All newlines translated to "\n" and 50 chars max + def short_msg(msg) + result = msg.chomp.gsub("\n", "\\n") + return result if result.size <= SHORT_MSG_LIMIT + result[0..SHORT_MSG_LIMIT-1] + "..." + end + + # Remove escaped percent characters in a text to avoid false positives + # during pattern matching. + def remove_escaped_percent(msg) + msg.gsub("%%", "") + end + + def current_file_unmodified? + @current_file_modifications == 0 + end + end + end + end +end + +if __FILE__ == $0 # if called as a standalone command + Yast::GetText::Tools::PoAddFormatHints.new.run(ARGV) +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/build-tools/scripts/y2makepot new/yast2-devtools-4.2.6/build-tools/scripts/y2makepot --- old/yast2-devtools-4.2.5/build-tools/scripts/y2makepot 2019-07-17 10:09:26.000000000 +0200 +++ new/yast2-devtools-4.2.6/build-tools/scripts/y2makepot 2020-05-06 17:19:20.000000000 +0200 @@ -16,6 +16,11 @@ CWD=`dirname $0` . $CWD/gettextdomains +# Helper script to add c-format or ycp-format markers; +# this is assumed to be in the same directory as this script. +PO_ADD_FORMAT_HINTS=$CWD/po_add_format_hints + + # list of generated files which should be removed at the end CLEAN_FILES="" @@ -87,6 +92,20 @@ # and do not pass the following check sed -i '/^"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;/d' $MODULE.pot + # Add format marker hints for placeholders: + # %s %d etc. -> c-format + # %1 %2 etc. -> ycp-format + # + # msgfmt and msgmerge understand those formats and will check if a + # translation has the same placeholders as the untranslated message. + # + # This can be overridden for each message in the source code with + # the usual xgettext comments: + # + # # xgettext:c-format + # # foo(_("... %1 ...")) + $PO_ADD_FORMAT_HINTS $MODULE.pot + # verify if the output is valid, rxgettext had some bugs resulting # in invalid file, be sure that GNU gettext is able to read it, huh :-( echo "Verifying $MODULE.pot validity..." diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/package/yast2-devtools.changes new/yast2-devtools-4.2.6/package/yast2-devtools.changes --- old/yast2-devtools-4.2.5/package/yast2-devtools.changes 2019-07-17 10:09:26.000000000 +0200 +++ new/yast2-devtools-4.2.6/package/yast2-devtools.changes 2020-05-06 17:19:20.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue May 5 13:20:44 UTC 2020 - Stefan Hundhammer <[email protected]> + +- New script to add format hints for translated messages: + po_add_format_hints (bsc#954505, bsc#980329) +- 4.2.6 + +------------------------------------------------------------------- Wed Jul 17 07:25:46 UTC 2019 - Ladislav Slezák <[email protected]> - Fixed syntax error in the RPM macros causing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/package/yast2-devtools.spec new/yast2-devtools-4.2.6/package/yast2-devtools.spec --- old/yast2-devtools-4.2.5/package/yast2-devtools.spec 2019-07-17 10:09:26.000000000 +0200 +++ new/yast2-devtools-4.2.6/package/yast2-devtools.spec 2020-05-06 17:19:20.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-devtools -Version: 4.2.5 +Version: 4.2.6 Release: 0 Url: https://github.com/yast/yast-devtools Summary: YaST2 - Development Tools @@ -136,6 +136,7 @@ %{_datadir}/YaST2/data/devtools/bin/showy2log %{_datadir}/YaST2/data/devtools/bin/tagversion %{_datadir}/YaST2/data/devtools/bin/y2makepot +%{_datadir}/YaST2/data/devtools/bin/po_add_format_hints %{_datadir}/YaST2/data/devtools/bin/gettextdomains %{_datadir}/YaST2/data/devtools/bin/ycp_puttext %{_datadir}/YaST2/data/devtools/data/rubocop_yast_style.yml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/test/Makefile.am new/yast2-devtools-4.2.6/test/Makefile.am --- old/yast2-devtools-4.2.5/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-devtools-4.2.6/test/Makefile.am 2020-05-06 17:19:20.000000000 +0200 @@ -0,0 +1,6 @@ +check-local: + if ruby -r rspec -e 0; then \ + rspec *_test.rb ;\ + else \ + echo Ruby or RSpec missing, tests skipped; \ + fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/test/data/hello.pot new/yast2-devtools-4.2.6/test/data/hello.pot --- old/yast2-devtools-4.2.5/test/data/hello.pot 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-devtools-4.2.6/test/data/hello.pot 2020-05-06 17:19:20.000000000 +0200 @@ -0,0 +1,46 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-04-28 17:42+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <[email protected]>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: hello.c:33 +msgid "Hello, world!\n" +msgstr "" + +#: hello.c:34 +msgid "How are you today?" +msgstr "" + +#: hello.c:36 +msgid "printf-like parameters %s and %s\n" +msgstr "" + +#: hello.c:37 +msgid "Numbered printf parameters %2$s and %1$s\n" +msgstr "" + +#: hello.c:40 +msgid "sformat-like message with parameters %1 and %2" +msgstr "" + +#: hello.c:45 +msgid "Named parameters %{foo} and %{bar}" +msgstr "" + +#: hello.c:46 +msgid "Named parameters %<foo> and %<bar>" +msgstr "" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/test/po_add_format_hints_test.rb new/yast2-devtools-4.2.6/test/po_add_format_hints_test.rb --- old/yast2-devtools-4.2.5/test/po_add_format_hints_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-devtools-4.2.6/test/po_add_format_hints_test.rb 2020-05-06 17:19:20.000000000 +0200 @@ -0,0 +1,112 @@ +#!/usr/bin/env rspec + +load "../build-tools/scripts/po_add_format_hints" + +describe Yast::GetText::Tools::PoAddFormatHints do + subject { described_class.new } + + describe "#new" do + it "Does not crash and burn" do + expect(subject).not_to be_nil + end + + it "Starts with reasonable defaults" do + expect(subject.dry_run).to be false + expect(subject.verbose).to be false + expect(subject.silent).to be false + expect(subject.total_modifications).to be == 0 + expect(subject.current_file_modifications).to be == 0 + end + end + + describe "#find_known_formats" do + it "Detects simple printf-like format strings: %s, %d, %x, ..." do + expect(subject.find_known_formats("%s")).to be == "c-format" + expect(subject.find_known_formats("foo %s bar")).to be == "c-format" + expect(subject.find_known_formats("foo %d bar")).to be == "c-format" + expect(subject.find_known_formats("foo %02x bar")).to be == "c-format" + expect(subject.find_known_formats("foo %1d bar")).to be == "c-format" + expect(subject.find_known_formats("foo %2s bar")).to be == "c-format" + end + + it "Detects more complex printf-like format strings: %-10.4d" do + expect(subject.find_known_formats("%2.1d")).to be == "c-format" + expect(subject.find_known_formats("%-10.4d")).to be == "c-format" + expect(subject.find_known_formats("%+10.4d")).to be == "c-format" + expect(subject.find_known_formats("% 10.4d")).to be == "c-format" + end + + it "Detects positional parameters in printf-like format strings: %1$d, %2$s, ..." do + expect(subject.find_known_formats("%1$d")).to be == "c-format" + expect(subject.find_known_formats("%1$s")).to be == "c-format" + expect(subject.find_known_formats("%2$s %1$s")).to be == "c-format" + end + + it "Detects sformat-like format strings: %1, %2, ..." do + expect(subject.find_known_formats("foo %1 bar")).to be == "ycp-format" + expect(subject.find_known_formats("%2 foo %1 bar")).to be == "ycp-format" + end + + it "Detects named parameters: %{foo}, %{bar}" do + expect(subject.find_known_formats("%{foo} is %{bar}")).to be == "perl-brace-format" + end + + it "Detects named parameters with underscore in the name: %{foo_bar}" do + expect(subject.find_known_formats("%{foo}")).to be == "perl-brace-format" + expect(subject.find_known_formats("%{foo_bar}")).to be == "perl-brace-format" + end + + it "Ignores named parameters with format spec: %<foo>s, %<bar>d" do + expect(subject.find_known_formats("%<foo>s is %<bar>d")).to be == nil + end + + it "Survives inconsistent formats: %1 %2d (c-format wins)" do + expect(subject.find_known_formats("%1 %2d")).to be == "c-format" + expect(subject.find_known_formats("%1s %2")).to be == "c-format" + end + + it "Can handle embedded newlines" do + expect(subject.find_known_formats("foo\nbar\n%s bar")).to be == "c-format" + end + + it "Can handle escaped percent signs" do + expect(subject.find_known_formats("foo 42%% bar")).to be == nil + expect(subject.find_known_formats("foo %%1 bar")).to be == nil + expect(subject.find_known_formats("foo %%s bar %1")).to be == "ycp-format" + expect(subject.find_known_formats("foo %%1 bar %s")).to be == "c-format" + end + + it "Can handle unescaped percent signs" do + expect(subject.find_known_formats("foo 42% bar")).to be == nil + expect(subject.find_known_formats("100% complete: %1")).to be == "ycp-format" + end + + it "Ignores named parameters if perl-brace-format is disabled" do + subject.perl_brace_format = false + expect(subject.find_known_formats("%{foo} is %{bar}")).to be == nil + subject.perl_brace_format = true + expect(subject.find_known_formats("%{foo} is %{bar}")).to be == "perl-brace-format" + end + end + + describe "#run" do + HELLO_POT = "#{__dir__}/data/hello.pot".freeze + + # Always use "--dry-run" to avoid modifying the sample .pot file! + it "Reports the expected number of changes" do + argv = ["--dry-run", HELLO_POT] + expect { subject.run(argv) }.to output(/^.*hello.pot: 4 format flags added$/).to_stdout + end + + it "Reports one less change when disabling perl-brace-format" do + argv = ["--dry-run", "--no-perl-brace-format", HELLO_POT] + expect { subject.run(argv) }.to output(/3 format flags added/).to_stdout + end + + it "Reports the added formats in verbose mode" do + argv = ["--dry-run", "--verbose", HELLO_POT] + added = /Adding c-format.*Adding c-format.*Adding ycp-format.*Adding perl-brace-format/m + expect { subject.run(argv) }.to output(added).to_stdout + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-devtools-4.2.5/ytools/yast2/create_maintenance_branch new/yast2-devtools-4.2.6/ytools/yast2/create_maintenance_branch --- old/yast2-devtools-4.2.5/ytools/yast2/create_maintenance_branch 2019-07-17 10:09:26.000000000 +0200 +++ new/yast2-devtools-4.2.6/ytools/yast2/create_maintenance_branch 2020-05-06 17:19:20.000000000 +0200 @@ -7,28 +7,34 @@ require "cheetah" if ARGV.size < 2 - STDERR.puts <<EOS -Bad arguments + warn <<~HELP + Bad arguments -First argument: name of the branch -Second argument: name of the target as recognized by yast-rake, see - https://github.com/yast/yast-rake/blob/master/data/targets.yml - second argument is also used for docker tag, just adds '-' before "sp" part -Third argument (optional): source commit, if not specified use master - -Examples: -#{File.basename($0)} SLE-12-SP1 sle12sp1 # creates branch for master -#{File.basename($0)} SLE-12-SP1 sle12sp1 abcdef # creates branch from commit abcdef -EOS + First argument: name of the branch + Second argument: name of the target as recognized by yast-rake, see + https://github.com/yast/yast-rake/blob/master/data/targets.yml + second argument is also used for docker tag, just adds '-' before "sp" part + Third argument (optional): source commit, if not specified use master + + Options: + + --dry-run Do not commit and push the changes, useful for testing + the changes. + + Examples: + #{File.basename($PROGRAM_NAME)} SLE-12-SP1 sle12sp1 # creates branch for master + #{File.basename($PROGRAM_NAME)} SLE-12-SP1 sle12sp1 abcdef # creates branch from commit abcdef + HELP exit(1) end +DRY_RUN = !!ARGV.delete("--dry-run") BRANCH_NAME = ARGV[0] TARGET = ARGV[1].delete(":") SOURCE_COMMIT = ARGV[2] || "origin/master" # by default pass output of commands to stdout and stderr -Cheetah.default_options = { :stdout => STDOUT, :stderr => STDERR } +Cheetah.default_options = { stdout: STDOUT, stderr: STDERR } def project raise unless @project @@ -39,7 +45,7 @@ NAMESPACES_MAPPING = { "libyui" => "Libyui", "yast" => "Yast" -} +}.freeze def project_namespace raise unless @project @@ -52,19 +58,17 @@ end def check_real_upstream - res = Cheetah.run "git", "remote", "-v", :stdout => :capture + res = Cheetah.run "git", "remote", "-v", stdout: :capture upstream = res.lines.grep(/origin\s*[email protected]:(yast|libyui)/) - if upstream.empty? - raise "This script can work only on upstream clone, where upstream remote is marked as origin" - end + raise "This script can work only on upstream clone, where upstream remote is marked as origin" if upstream.empty? self.project = upstream.first[/origin\s*[email protected]:(yast|libyui)/, 1] end def already_exists? - res = Cheetah.run "git", "branch", "-r", :stdout => :capture + res = Cheetah.run "git", "branch", "-r", stdout: :capture res = res.lines - return !res.grep(/origin\/#{BRANCH_NAME}/).empty? + !res.grep(/origin\/#{BRANCH_NAME}\z/).empty? end def modify_rakefile @@ -74,11 +78,11 @@ submit_to = "#{project_namespace}::Tasks.submit_to" new_line = "#{submit_to} :#{TARGET}\n" - line_index = lines.index {|l| l =~ /#{submit_to}/ } + line_index = lines.index { |l| l =~ /#{submit_to}/ } if line_index lines[line_index] = new_line else # line is not there yet, so place it below require line - line_index = lines.index {|l| l =~ /^\s*require.*#{project}\/rake/ } + line_index = lines.index { |l| l =~ /^\s*require.*#{project}\/rake/ } lines.insert(line_index + 1, "\n", new_line) end @@ -87,20 +91,38 @@ def modify_dockerfile if !File.exist?("Dockerfile") - STDERR.puts "No Dockerfile, skipping its adaptation" + warn "No Dockerfile, skipping its adaptation" return end lines = File.readlines("Dockerfile") from_index = lines.index { |l| l =~ /^FROM / } raise "Missing FROM in dockerfile" unless from_index + line = lines[from_index] - docker_tag = ":" + TARGET.sub(/sp/, "-sp") - if line.include?(":") # docker file already use tag - line.sub!(/:.*$/, docker_tag + "\n") + + if line.include?("registry.opensuse.org") + # new OBS Docker image + project_path = TARGET.sub(/sp/, "/sp").sub(/sle/, "sle-") + + registry = if project == "yast" + img_type = line.include?("cpp") ? "cpp" : "ruby" + "registry.opensuse.org/yast/#{project_path}/containers/yast-#{img_type}" + else + "registry.opensuse.org/devel/libraries/libyui/#{project_path}/containers/libyui-devel" + end + + line.replace("FROM #{registry}\n") else - line.sub!(/\s*$/, docker_tag + "\n") + # old Docker Hub image + docker_tag = ":" + TARGET.sub(/sp/, "-sp") + if line.include?(":") # docker file already use tag + line.sub!(/:.*$/, docker_tag + "\n") + else + line.sub!(/\s*$/, docker_tag + "\n") + end end + File.write("Dockerfile", lines.join("")) end @@ -111,10 +133,10 @@ exit 0 end -#switch to master branch +# switch to master branch Cheetah.run "git", "checkout", "master" -#create new branch ( ensure we use the latest non modified pushed version ) +# create new branch ( ensure we use the latest non modified pushed version ) Cheetah.run "git", "fetch", "origin" Cheetah.run "git", "branch", BRANCH_NAME, SOURCE_COMMIT Cheetah.run "git", "checkout", BRANCH_NAME @@ -122,10 +144,14 @@ modify_rakefile modify_dockerfile -commit_msg = "adapt Rakefile and Dockerfile for #{BRANCH_NAME}" - -Cheetah.run "git", "commit", "-am", commit_msg +commit_msg = "Adapt Rakefile and Dockerfile for #{BRANCH_NAME}" -Cheetah.run "git", "push", "--set-upstream", "origin", "#{BRANCH_NAME}:#{BRANCH_NAME}" - -puts "Maintenance branch properly created" +if DRY_RUN + puts "Dry run mode active, run these commands to manually push the changes:" + puts " git commit -am \"#{commit_msg}\"" + puts " git push --set-upstream origin #{BRANCH_NAME}:#{BRANCH_NAME}" +else + Cheetah.run "git", "commit", "-am", commit_msg + Cheetah.run "git", "push", "--set-upstream", "origin", "#{BRANCH_NAME}:#{BRANCH_NAME}" + puts "Maintenance branch properly created" +end
