git: exit early if Git is found but too old (Issue #342)
The warning in the logs were too easy to miss.
It is still OK if git isn't found at all... for example if git_path configuration doesn't point at something that looks like git.
The git_path configuration already had no default, so just make the code path for that case more clean. (An easy next/alternative step could be to remove git from BACKENDS if it isn't configured ...)
The system exit is similar to what is done in 0e33880b2897 ... even though exiting from from a library might be a bit worse ...
Align the comment headers in all kallithea.po translation files: - remove the description of the file: for new translations added via Weblate, this is not updated and it'd contain 'Translations template for Kallithea'. The name of the language is already present later in the file in the metadata block. - remove 'Automatically generated' lines present in some files - add an empty line below the header block
i18n: remove source code references from kallithea.po files
Remove all comments with source code references from the kallithea.po files. Such meta data will inherently be outdated, and create unnecessary churn and repository growth, making it harder to spot actual and important changes.
None of the removed information is actually 'lost', it can be regenerated via extract_messages/msgmerge, see instructions in kallithea/i18n/how_to.
This commit is part of a series that normalizes the kallithea.po files by removing all comments, in particular source code references.
This information can be useful to translators in the future and therefore will be preserved in a separate kallithea-i18n repository with separate *-i18n branches.
This commit is part of a series that normalizes the kallithea.po files by removing all comments, in particular source code references.
Remove translations of strings that are no longer used in Kallithea.
These translations can be useful to translators in the future and therefore will be preserved in a separate kallithea-i18n repository with separate *-i18n branches.
This commit is part of a series that normalizes the kallithea.po files by removing all comments, in particular source code references.
These contributors are already present in repository history for the specified years. The entries can be removed from 'contributor_data' without impact in CONTRIBUTORS or the about page.
contributors: fix existing email-less entry of 'mikespook'
Commit 17bef51d7616 was committed as 'mikespook' without any email address. This name was thus reflected without email in the CONTRIBUTORS file.
In the i18n copyright data, a 'mikespook' _with_ email address was referenced. Assuming these two refer to the same person, add a 'name fix' to combine them.
In scripts/contributor_data.py, there are already two 'name fixes' for 'marcink' and 'Marcin Kuzminski' to align all contributions with these names to a specific name and email address.
Assuming they want to use the single email address as specified earlier, we map the entry 'marcinkuzminski' in the i18n .po files on the same name/email.
tg2: handle cache_dir configuration jumping around between TurboGears versions
Tweak 87672c1916f8 - the use of 'tg.cache_dir' turns out to not be a good idea.
TurboGears 2.4 moved 'cache_dir' configuration to the expected 'cache_dir' key, and no longer has 'tg.cache_dir' ... and also not the old 'app_conf'.'cache_dir' .
tg2: move routing mapper initialization from RootController class definition time to instantiation time
Things happened to work before, despite unfortunate code executation at import time. TurboGears 2.4 changed something, so actual serving works, but pytest fails with:
collecting ... ... data/env/lib/python2.7/site-packages/_pytest/config/__init__.py:463: in _importconftest raise ConftestImportFailure(conftestpath, sys.exc_info()) E ConftestImportFailure: (local('.../kallithea/tests/conftest.py'), (<type 'exceptions.KeyError'>, KeyError('paths',), <traceback object at 0x7fb6679030e0>))
or more useful, if raising the real exception instead of obfuscating with ConftestImportFailure:
... kallithea/tests/conftest.py:15: in <module> from kallithea.controllers.root import RootController kallithea/controllers/root.py:29: in <module> class RootController(RoutedController, BaseController): kallithea/controllers/root.py:31: in RootController mapper = make_map(config) kallithea/config/routing.py:32: in make_map rmap = Mapper(directory=config['paths']['controllers'], data/env/lib/python2.7/site-packages/tg/configuration/tgconfig.py:28: in __getitem__ return self.config_proxy.current_conf()[key] E KeyError: 'paths' _importconftest <_pytest.config.PytestPluginManager object at 0x7f20c770a3d0> .../conftest.py
In this example, in RootController, the global config object is at this time just:
The documentation stated that a theme.less file can be placed in the Kallithea root directory, but this is not true. The file is expected in kallithea/front-end to take effect.
scm: select options should be tuples - not lists with 2 elements
We use tuples in all(?) other places, so we should do the same here.
Since lists can be unpacked as tuples, it currently works to use 2-lists. But in a following change for "correct" handling of webhelpers.select when using webhelpers2.select, we want to give special handling to tuples vs strings vs Options. We don't want to add list to that list.
Performing ssh actions towards Kallithea via an IPv6 connection gave the following error:
$ hg incoming ssh://kallithea@example.com/repo remote: Traceback (most recent call last): remote: File ".../bin/kallithea-cli", line 11, in <module> remote: load_entry_point('Kallithea', 'console_scripts', 'kallithea-cli')() remote: File ".../python2.7/site-packages/click/core.py", line 764, in __call__ remote: return self.main(*args, **kwargs) remote: File ".../python2.7/site-packages/click/core.py", line 717, in main remote: rv = self.invoke(ctx) remote: File ".../python2.7/site-packages/click/core.py", line 1137, in invoke remote: return _process_result(sub_ctx.command.invoke(sub_ctx)) remote: File ".../python2.7/site-packages/click/core.py", line 956, in invoke remote: return ctx.invoke(self.callback, **ctx.params) remote: File ".../python2.7/site-packages/click/core.py", line 555, in invoke remote: return callback(*args, **kwargs) remote: File ".../kallithea/bin/kallithea_cli_base.py", line 79, in runtime_wrapper remote: return annotated(*args, **kwargs) remote: File ".../kallithea/bin/kallithea_cli_ssh.py", line 74, in ssh_serve remote: vcs_handler.serve(user_id, key_id, client_ip) remote: File ".../kallithea/lib/vcs/backends/ssh.py", line 65, in serve remote: self.authuser = AuthUser.make(dbuser=dbuser, ip_addr=client_ip) remote: File ".../kallithea/lib/auth.py", line 407, in make remote: if not check_ip_access(source_ip=ip_addr, allowed_ips=allowed_ips): remote: File ".../kallithea/lib/auth.py", line 860, in check_ip_access remote: if ipaddr.IPAddress(source_ip) in ipaddr.IPNetwork(ip): remote: File ".../kallithea/lib/ipaddr.py", line 76, in IPAddress remote: remote: ValueError: '2' does not appear to be an IPv4 or IPv6 address abort: no suitable response from remote hg!
This was caused by IPv4-exclusive parsing of the SSH_CONNECTION variable. With an IPv6 address starting with '2a02:1810:', only the first '2' would survive.
According to 'man 1 ssh':
SSH_CONNECTION Identifies the client and server ends of the con‐ nection. The variable contains four space-sepa‐ rated values: client IP address, client port num‐ ber, server IP address, and server port number.
So, the client IP address will be the first space-separated word, regardless of IPv4 or IPv6. Use that knowledge without further parsing.
kallithea-cli: use null handler to mute all console logging for ssh-serve
Augment logger_root to use the null handler when running ssh-serve. Set the log level to CRITICAL to filter early and minimize the amount of logging sent to the null handler.
It is however recommended to configure the system to use some logging facility that can handle logging for SSH access from many different processes.
kallithea-cli: introduce generic custom logging configuration for each cli command
Command line commands have different needs for logging than the server process.
To enable that use case, allow config sections to be enabled (and thus augment existing sections), depending on which kallithea-cli command is running.
kallithea-cli: set ssh_locale when creating .ini file so it doesn't have to be set manually before using ssh
The Python standard library does not seem to provide a simple way to determine the current locale without calling locale.setlocale() and thus potentially influencing the rest of the program.
Instead, try to determine the locale based on environment variables present when 'kallithea-cli config-create' is run, and use it to prepopulate the ini file.
In the SSH client configuration, the setting 'SendEnv' could contain variables like 'LANG', 'LC_ALL', and others. This causes these environment variables (with their values at the client-side) to be set in the server. However, not every locale setting valid in the client, is also valid on the server.
This could lead to the error: 'locale.Error: unsupported locale setting' when 'from mercurial import archival, merge as hg_merge, patch, ui' is called.
Fix this problem by providing an ini setting 'ssh_locale' that the user can set correctly, and which will be used to set LC_ALL and LANGUAGE in the 'kallithea-cli ssh-serve' process.
If an environment variable LC_ALL is set, it takes precedence over all other 'LC_xxx' variables, as well as over LANG. So, setting LC_ALL ensures that no user setting of 'LC_xxx' or 'LANG' could influence ssh-serve badly.
There is one environment variable that might overrule LC_ALL, specifically for showing messages: 'LANGUAGE'. GNU gettext lets it take precedence over LC_ALL [1]: "GNU gettext gives preference to LANGUAGE over LC_ALL and LANG for the purpose of message handling"
So, also set LANGUAGE to the same value as we set LC_ALL to.
The principle of setting a specific locale in the server process to fix this error, was first proposed by Dominik Ruf.
Text related to the case where the parent directory of 'authorized_keys' does not exist or is not writable, was contributed by Bradley M. Kuhn <bkuhn@ebb.org>.
ssh: add clone_ssh_tmpl setting when migration database for SSH
It is slightly dangerous to use the db model in the alembic migration script ... but in this simple case we do it anyway. It is also a bit dirty to modify an existing migration script, but in this case the changes are landing at once and it is only about making the migration process slightly more smooth.
This commit also incorporates a fix for Windows by Dominik Ruf, and better handling of the case where the parent dir of 'authorized_keys' does not exist or is not writable, by Bradley M. Kuhn <bkuhn@ebb.org>.
Error reporting when using SSH is different from when using HTTP. SSH doesn't use HTTP error codes but can write anything to stdout/stderr. Some tests thus need to have their expectations tweaked.
Based on work by Ilya Beda <ir4y.ix@gmail.com> on https://bitbucket.org/ir4y/rhodecode/commits/branch/ssh_server_support . Bootstrap support, updates for POST methods, and tests by Anton Schur <tonich.sh@gmail.com>. Additional Bootstrap fixes by Dominik Ruf. Also heavily modified by Mads Kiilerich.