|
|
Mads Kiilerich
|
2a57d3660003
|
4 years ago
|
|
git: show warning when removing existing unused Kallithea hook
These hooks are no longer used and should be removed, but it is nice to have explicit logging when it happens.
|
|
|
Mads Kiilerich
|
092e897458fa
|
5 years ago
|
|
hg: read hgrc, also in repo_scan
This might make a difference in some real world cases.
|
|
|
Mads Kiilerich
|
3b5657fba7f3
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
8c7bbe5bd032
|
5 years ago
|
|
hooks: when overwriting non-Kallithea hooks, move the old hook to .bak
Note: This will only happen when actually overwriting an unknown hook. Repeated hook installation will thus not clobber the existing .bak file until a non-Kallithea hook is found again.
|
|
|
Mads Kiilerich
|
fff835606650
|
5 years ago
|
|
|
|
|
Thomas De Schampheleire
|
0b1a23b88f9a
|
5 years ago
|
|
cleanup: get rid of redundant assignments 'foo = foo' Redundant assignments were searched with: grep '^ *\(.*\) = \1$' `hg files` Some of these cases have resulted from earlier cleanup, like: foo = safe_unicode(foo) and later batch removing safe_unicode usage. See e.g. commit e35373106528b29461b7f5144780cb9ec79f765d . Note: two false positives occur: kallithea/tests/models/test_settings.py:39: setting.app_settings_value = setting.app_settings_value kallithea/tests/models/test_settings.py:42: setting.app_settings_value = setting.app_settings_value which is not a plain assignment but where 'app_settings_value' is a property method with side effects.
|
|
|
Mads Kiilerich
|
259213d96dca
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
9b7c5d7ad1a2
|
5 years ago
|
|
hooks: import whole hooks module
Minimize impact if there should be cycles.
|
|
|
Mads Kiilerich
|
7b809e4a1ea5
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
1089fac66e81
|
5 years ago
|
|
git: detect existing symlink hooks before overwriting - only update plain files
If the existing hook is a symlink, the hook is not what we put in place, and we should stay away - no matter if it points at something that looks like a Kallithea hook.
|
|
|
Mads Kiilerich
|
6a90b1ebea2c
|
5 years ago
|
|
git: write Git hook files atomically
Make sure we don't follow symlinks or inherit permissions from previously installed hook.
|
|
|
Mads Kiilerich
|
3f1e5ec89bfc
|
5 years ago
|
|
git: minor refactor and clean-up of hook installation code
Make "pre-receive" and "post-receive" more explicit and grepable.
|
|
|
Mads Kiilerich
|
aee4c451566f
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
912563696e9e
|
5 years ago
|
|
scm: simplify InMemoryChangeset handling
Avoid conditional imports.
|
|
|
Mads Kiilerich
|
5e46f73f0d1c
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
dff9658bdd98
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
d332fca29474
|
5 years ago
|
|
config: move various py templates to kallithea/templates/py/
For some reason, we had some python templates in kallithea/config . kallithea.config is mainly the TG entry point, and thus a high level controller thing - not a place to store templates.
Instead, use the templates directory and introduce a new py subdirectory.
With git hook templates in a templates directory, there is no need for tmpl in the name.
|
|
|
Mads Kiilerich
|
2ff983214ea0
|
5 years ago
|
|
imports: always import the whole kallithea module to use top level kallithea variables
This is slightly more lazy and might avoid some depeendency issues.
|
|
|
Mads Kiilerich
|
bbd96bdf8372
|
5 years ago
|
|
scm: make sure __get_repo always returns something
Avoid pytype complaint: File ".../kallithea/model/scm.py", line 438, in get_nodes: No attribute 'scm_instance' on None [attribute-error] In Optional[Any]
Avoid invoking __get_repo with None as parameter when creating repos.
|
|
|
Mads Kiilerich
|
eb486c0c3114
|
5 years ago
|
|
scm: refactor install_git_hooks
Rename, simplify, and negate some logic to make the flow more readable to me and give better logging.
For example, "force_create" were more about "force overwrite". Calling it "force" is more precise.
|
|
|
Mads Kiilerich
|
ed92c3b846c7
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
c19e720cbb21
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
e63bcce18fef
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
e51ad2cd400e
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
e35373106528
|
6 years ago
|
|
py3: remove safe_unicode in places where it no longer is needed because all strings (except bytes) already *are* unicode strings
(The remaining safe_unicode calls are still needed and can't just be removed, generally because we in these cases still have to convert from bytes to unicode strings.)
|
|
|
Mads Kiilerich
|
fb4b72c1c0f1
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
756e46bd926b
|
6 years ago
|
|
py3: trivial renaming of .iteritems() to .items()
A bit like "2to3 -f dict", but we don't want list().
|
|
|
Mads Kiilerich
|
aa6f17a53b49
|
6 years ago
|
|
py3: switch to use Python 3 interpreter, temporarily leaving many things very broken until they have been migrated/fixed in a reviewable way
Bump Mercurial minimum version to 5.2 - the first version that claim stable py3 support.
|
|
|
Mads Kiilerich
|
5ddd6b930dd0
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
45bfab30d433
|
6 years ago
|
|
py3: add b'' annotations in some places where they will be needed later
Mostly entirely trivial adding of b prefix that is a ignored for py2 ... and also a bit of related trivial reformatting/refactorings.
|
|
|
Mads Kiilerich
|
45497a4524aa
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
d9d03f138cc3
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
fd0998635e83
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
d4ea298c3ec4
|
6 years ago
|
|
cleanup: minor refactorings and simplification of dict usage
Makes it more py3 compatible.
|
|
|
Mads Kiilerich
|
b0c75d6f8f32
|
6 years ago
|
|
py3: use explicit octal literals
From 2to3 numliterals.
|
|
|
Mads Kiilerich
|
5a971de9741c
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
c809987a2839
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
496df7eb2bc2
|
6 years ago
|
|
model: use repo.set_invalidate() instead of accesssing CacheInvalidation directly
Trying to contain the use of CacheInvalidation ...
|
|
|
Mads Kiilerich
|
e6b9194ab3f8
|
6 years ago
|
|
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.
|
|
|
Mads Kiilerich
|
fe4086096758
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
0a277465fddf
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
7c5d28775cdf
|
7 years ago
|
|
|
|
|
Mads Kiilerich
|
7ba73396e5ba
|
7 years ago
|
|
hooks: move _handle_rc_scm_extras to utils2 as set_hook_environment and get_hook_environment
This is also a step away from using the name 'extras' ... but still a lot of traces left behind ...
|
|
|
Mads Kiilerich
|
16df4993b442
|
7 years ago
|
|
scm: don't try to get IP address from web request in model
Remove a layering violation and make functions more reusable when they no longer depend on global state.
At this level, the IP address (and information about the current user) is only used for hooks logging push / pull operations. Arguably, IP address logging only belongs in an HTTP access log, not in the log of push/pull operations. But as long as we have IP addresses in the logs, we have to provide it. The (good?) alternative would be to drop IP address from the push / pull logs ...
|
|
|
Mads Kiilerich
|
a93b8a544f83
|
7 years ago
|
|
hooks: drop 'server_url' parameter
The parameter might be conceptually nice, but it was only available for 2 hooks. To be really useful, it should have been available everywhere. It also only reported the URL from the web request that initiated the hook ... and as such it does some layering violations. The user URL might be the address that should be used internally from the hook. And it can conceptually not be made available actions that doesn't originate from a user web request. It seems much better that custom hooks configure what they want to do. Perhaps by reading the .ini file and using canonical_url.
|
|
|
Mads Kiilerich
|
c8239333853d
|
7 years ago
|
|
hooks: refactor log_push_action The core of the functionality is to process a list of "raw id"s, log them, and update / invalidate caches. handle_git_post_receive and scm _handle_push already provide that list directly. Things get much simpler when introducing a new function (process_pushed_raw_ids) just for processing pushed raw ids. That also makes it clear that scm _handle_push doesn't need any repo. log_push_action remains the native entry point for the Mercurial hook. It was not entirely correct using 'node:tip' - after Mercurial 3.7 and d6d3cf5fda6f, it should be 'node:node_last'. After several trivial refactorings, it turns out that the logic for creating the hash list for Mercurial actually is very simple ...
|
|
|
Mads Kiilerich
|
5b551b189459
|
7 years ago
|
|
utils: refactor make_ui to always read from db, optionally also augmenting with hgrc content
simplehg was the only user of reading hgrc content ... and it would rather just have everything at once.
The implementation in utils is moved around and re-indented, but without significant changes.
|
|
|
Mads Kiilerich
|
99edd97366e3
|
7 years ago
|
|
locking: drop the pull-to-lock / push-to-unlock functionality
The feature is not worth the maintenance cost. The locking is too coarse and unflexible with insufficient UI and UX. The implementation is also quite invasive in tricky areas of the code, and thus high maintenance. Dropping this will enable other cleanup ... or at least make it easier.
|
|
|
Thomas De Schampheleire
|
1bafb2d07709
|
7 years ago
|
|
hooks: make the Python interpreter for Git hooks configurable as 'git_hook_interpreter' (Issue #333) Commit 5e501b6ee639 introduced the use of 'sys.executable' as interpreter for git hooks instead of 'python2' with the following argument: "Windows doesn't necessarily have "python2" available in $PATH, but we still want to make sure we don't end up invoking a python3. Using the absolute path seems more safe." But, sys.executable does not necessarily point to Python. When Kallithea is started under uWSGI, sys.executable points to the uwsgi executable. As a result, the interpreter encoded in the git hooks on the server repositories would be: #!/path/to/uwsgi And pushing to such repo would result in following client errors: $ git push Password for ' http://user@localhost:5050': Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 241 bytes | 241.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: unable to load configuration from hooks/pre-receive To http://localhost:5050/gitrepo-new ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to ' http://user@localhost:5050/gitrepo-new' Fix this problem by introducing a configuration setting 'git_hook_interpreter' that allow administrators to specify which Python interpreter to use. A subsequent commit will cause its value to be filled in automatically when generating a new ini file, but an administrator can always override it.
|
|
|
Thomas De Schampheleire
|
dd88fd3a45cc
|
7 years ago
|
|
hooks: use /usr/bin/env only when needed The use of /usr/bin/env is only needed for relative arguments (or to pass variables in the environment, which we don't do). It is thus not needed in case the Python interpreter for Git hooks is known with absolute path, as introduced in 5e501b6ee639.
|
|
|
Thomas De Schampheleire
|
98deccab042c
|
7 years ago
|
|
hooks: add intermediate function _get_git_hook_interpreter
The logic to determine the right interpreter for Git hooks is about to change and possibly become more complex. Split it off in a separate function so such changes do not require extra code duplication and preserve the readability of the code.
|
|
|
Thomas De Schampheleire
|
19af3fef3b34
|
7 years ago
|
|
|
|
|
Thomas De Schampheleire
|
b8deb93894ea
|
7 years ago
|
|
model/scm: fix incorrect reporting of pull from remote git repo
In issue #327 it was reported that the pull of a remote git repo causes the following inaccurate journal entry: "committed via Kallithea into repository"
The problem is caused by the following flow:
1. pull_changes calls _handle_push for git repos, passing action='push_remote'.
2. _handle_push calls _handle_rc_scm_extras, but does not pass 'action'
3. _handle_rc_scm_extras uses a default value of 'push_local' for action.
4. The action string 'push_local' will result in the mentioned journal entry, via action_map in action_parser() (kallithea/lib/helpers.py).
To get a more accurate log entry, _handle_push should pass the action that it got from pull_changes. In that case, the log entry will become "pulled from remote into repository"
|
|
|
Thomas De Schampheleire
|
85d812ab4c64
|
8 years ago
|
|
api: allow pulling from a custom remote
The 'pull' API call would currently pull from the configured repository remote or the fork origin in case of a fork.
This commit allows to specify an optional 'clone_uri' parameter to the API call that will be used during the pull.
|
|
|
Lars Kruse
|
7691290837d2
|
8 years ago
|
|
codingstyle: trivial whitespace fixes
Reported by flake8.
|
|
|
Mads Kiilerich
|
5cc6a3308a8f
|
9 years ago
|
|
repo-scan: rewrite get_filesystem_repos to use os.walk instead of stupid recursion
I think this is more readable. It is also faster. Perhaps because the more readable implementation makes it easier to optimize.
|
|
|
domruf
|
8390da12aa16
|
9 years ago
|
|
repositories: allow to pull changes from forked repo
It should be possible to pull changes not only from remote, but also from locally forked repositories.
|
|
|
Mads Kiilerich
|
e9ac5698281d
|
9 years ago
|
|
tg: minimize future diff by some mocking and replacing some pylons imports with tg
No actual tg dependency yet, just a temporary hack faking tg as an alias for pylons.
Based on work by Alessandro Molina.
|
|
|
Søren Løvborg
|
3760df6251e0
|
9 years ago
|
|
model: remove BaseModel class
The only remaining purpose of this class was to provide the "sa" field, allowing a custom SQLAlchemy session to be used for model operations. However, this never actually worked, nor was it used anywhere.
There's always a global SQLAlchemy session associated with the current thread; using another session for a single function call does not make any sense (as sessions cannot be mixed), unless the code works carefully to ensure the two sessions (and all objects loaded from them) are kept completely separate. Suffice to say that Kallithea does no such thing, thus there's no need to pretend to support multiple concurrent sessions.
|
|
|
Søren Løvborg
|
6edba875451d
|
9 years ago
|
|
cleanup: drop superfluous Session.add calls
Session.add should only be called on newly created database objects.
Per the Kallithea contribution guidelines:
When getting an object from the session (via Session().query or any of the utility functions that look up objects in the database), it's already part of the session, and should not be added again.
|
|
|
Søren Løvborg
|
ca77c6da2d34
|
9 years ago
|
|
auth: simplify user group permission checks
In practice, Kallithea has the 'usergroup.admin' permission imply the 'usergroup.write' permission, which again implies 'usergroup.read'.
This codifies this practice by replacing the HasUserGroupPermissionAny "perm function" with the new HasUserGroupLevel function, reducing the risk of errors and saving quite a lot of typing.
|
|
|
Søren Løvborg
|
b4d1e85265c1
|
9 years ago
|
|
auth: simplify repository group permission checks
In practice, Kallithea has the 'group.admin' permission imply the 'group.write' permission, which again implies 'group.read'.
This codifies this practice by replacing HasRepoGroupPermissionAny "perm function" with the new HasRepoGroupLevel function, reducing the risk of errors and saving quite a lot of typing.
|
|
|
Søren Løvborg
|
a17c8e5f6712
|
9 years ago
|
|
auth: simplify repository permission checks
In practice, Kallithea has the 'repository.admin' permission imply the 'repository.write' permission, which again implies 'repository.read'.
This codifies/enforces this practice by replacing HasRepoPermissionAny "perm function" with the new HasRepositoryLevel function, reducing the risk of errors and saving quite a lot of typing.
|
|
|
Søren Løvborg
|
d7d1e0a3850a
|
9 years ago
|
|
|
|
|
Søren Løvborg
|
eb1a4c3cb76c
|
9 years ago
|
|
|
|
|
Søren Løvborg
|
2d216fd7d5a2
|
9 years ago
|
|
db: rename UserFollowing.follows_repo_id to follows_repository_id
Since the relationship is 'follows_repository', rename the column to be 'follows_repository_id', not 'follows_repo_id'. This also makes the Python column name match the actual database column name.
(The inconsistency dates back to early RhodeCode days.)
|
|
|
Søren Løvborg
|
36e22160e5e5
|
9 years ago
|
|
db: rename RepoGroup.group_parent_id to parent_group_id
Also for consistency with the existing parent_group relationship.
|
|
|
Thomas De Schampheleire
|
d75d9ce1320d
|
9 years ago
|
|
model: move code from __init__.py to base.py Having too much code, in particular too much imports, inside a package's __init__.py is a recipe for circular imports, and considered bad practice in Python [1] Move out everything from kallithea/model/__init__.py to a new file kallithea/model/base.py and adapt the existing imports. [1] http://docs.python-guide.org/en/latest/writing/structure/#packages
|
|
|
Søren Løvborg
|
09bcde0eee6d
|
9 years ago
|
|
auth: remove HasPermissionAll and variants
First, find all calls to HasPermissionAll with only a single permission given, and convert to equivalent calls to HasPermissionAny.
Next, observe that it's hard to envision situations requiring multiple permissions (of the same scope: global/repo/repo group) to be satisfied. Sufficiently hard that there are actually no such examples in the code.
Finally, considering that (should it ever be needed) HasPermissionAll can be trivially built as a conjunction of HasPermissionAny calls (the decorators, too) with only a small performance impact, simply remove HasPermissionAll and related classes and functions.
|
|
|
Mads Kiilerich
|
186bf5fee0a1
|
9 years ago
|
|
repo-scan: rewrite get_filesystem_repos to use os.walk instead of stupid recursion
I think this is more readable. It is also faster. Perhaps because the more readable implementation makes it easier to optimize.
|
|
|
domruf
|
b313d735d9c8
|
9 years ago
|
|
|
|
|
domruf
|
5e501b6ee639
|
10 years ago
|
|
hooks: if available, use sys.executable as executable for git hooks
Windows doesn't necessarily have "python2" available in $PATH, but we still want to make sure we don't end up invoking a python3. Using the absolute path seems more safe.
|
|
|
Mads Kiilerich
|
b03233c4a438
|
10 years ago
|
|
scm: simplify get_repos and get rid of RepoList overloads
The RepoList variants might have made sense before any repo info was stored in the database. Now it has no value and doesn't help at all.
|
|
|
domruf
|
20bf8e618bc9
|
10 years ago
|
|
windows: node paths should always use posixpath - avoid \ in repo internal paths on windows
Using \ on Windows would result in a wrong node path which could not be checked out with Git on Windows.
|
|
|
domruf
|
3d09266ba8cb
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
edb24bc0f71a
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
aa1891074dd6
|
10 years ago
|
|
cache: when invalidating a cache, always just delete all 'live cache' records instead of marking them inactive
Keep it simple. Adding the record again might be slightly more expensive than just updating the active flag but instead we get get a simpler model and automatic cleanup without using the cache-keys paster command.
|
|
|
Søren Løvborg
|
431689d7f37d
|
10 years ago
|
|
remove vestiges of Python 2.5 support
We only support Python 2.6 and 2.7; hence we do not need to import with-statement support from __future__.
|
|
|
branko
|
c3d83238afa1
|
10 years ago
|
|
git: add option for forcing overwrite of Git hooks when remapping and rescanning the repositories. (Issue #153)
README file was updated to include some information on updating Git hooks after migrating to Kallithea.
|
|
|
Mads Kiilerich
|
061ce7c3071a
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
0210d0b769d4
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
d69aa464f373
|
10 years ago
|
|
cleanup: consistently use 'except ... as ...:'
Use the Python 2.6+ syntax instead of the old confusing 'except ..., ...' syntax.
|
|
|
Mads Kiilerich
|
63bed817308c
|
10 years ago
|
|
cleanup: check for None object identity in cases where that is what the 'contract' says
Avoid applying bool() on complex objects - it might return something unexpected such as the key (which might be 0 and thus be false). Checking for None is more safe and faster.
|
|
|
Mads Kiilerich
|
8e87c16ac58e
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
28db71c6349e
|
10 years ago
|
|
scm: introduce AvailableRepoGroupChoices
Extract reusable code to reduce code duplication.
Note: groups_choices from the db module is only used from this function and should perhaps also be extracted ... but it is also closely related to other stuff that is (mis)placed in the db module so perhaps not ...
|
|
|
Thomas De Schampheleire
|
494b04a84a49
|
11 years ago
|
|
|
|
|
Na'Tosha Bard
|
1f94dd1e2757
|
11 years ago
|
|
|
|
|
Na'Tosha Bard
|
54df936a9bd3
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
24c0d584ba86
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
1948ede028ef
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
ad38f9f93b3b
|
11 years ago
|
|
Correct licensing information in individual files.
The top-level license file is now LICENSE.md.
Also, in various places where there should have been joint copyright holders listed, a single copyright holder was listed. It does not appear easy to add a link to a large list of copyright holders in these places, so it simply refers to the fact that various authors hold copyright.
In future, if an easy method is discovered to link to a list from those places, we should do so.
Finally, text is added to LICENSE.md to point to where the full list of copyright holders is, and that Kallithea as a whole is GPLv3'd.
|
|
|
Bradley M. Kuhn
|
5b3bbffea092
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
9daad8c50b37
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
d1addaf7a91e
|
11 years ago
|
|
Second step in two-part process to rename directories. This is the actual directory rename.
|