Show More
@@ -26,6 +26,7 b' from .hooks import (' | |||||
26 | _pre_create_user_hook, |
|
26 | _pre_create_user_hook, | |
27 | _create_user_hook, |
|
27 | _create_user_hook, | |
28 | _comment_commit_repo_hook, |
|
28 | _comment_commit_repo_hook, | |
|
29 | _comment_edit_commit_repo_hook, | |||
29 | _delete_repo_hook, |
|
30 | _delete_repo_hook, | |
30 | _delete_user_hook, |
|
31 | _delete_user_hook, | |
31 | _pre_push_hook, |
|
32 | _pre_push_hook, | |
@@ -35,6 +36,7 b' from .hooks import (' | |||||
35 | _create_pull_request_hook, |
|
36 | _create_pull_request_hook, | |
36 | _review_pull_request_hook, |
|
37 | _review_pull_request_hook, | |
37 | _comment_pull_request_hook, |
|
38 | _comment_pull_request_hook, | |
|
39 | _comment_edit_pull_request_hook, | |||
38 | _update_pull_request_hook, |
|
40 | _update_pull_request_hook, | |
39 | _merge_pull_request_hook, |
|
41 | _merge_pull_request_hook, | |
40 | _close_pull_request_hook, |
|
42 | _close_pull_request_hook, | |
@@ -43,6 +45,7 b' from .hooks import (' | |||||
43 | # set as module attributes, we use those to call hooks. *do not change this* |
|
45 | # set as module attributes, we use those to call hooks. *do not change this* | |
44 | CREATE_REPO_HOOK = _create_repo_hook |
|
46 | CREATE_REPO_HOOK = _create_repo_hook | |
45 | COMMENT_COMMIT_REPO_HOOK = _comment_commit_repo_hook |
|
47 | COMMENT_COMMIT_REPO_HOOK = _comment_commit_repo_hook | |
|
48 | COMMENT_EDIT_COMMIT_REPO_HOOK = _comment_edit_commit_repo_hook | |||
46 | CREATE_REPO_GROUP_HOOK = _create_repo_group_hook |
|
49 | CREATE_REPO_GROUP_HOOK = _create_repo_group_hook | |
47 | PRE_CREATE_USER_HOOK = _pre_create_user_hook |
|
50 | PRE_CREATE_USER_HOOK = _pre_create_user_hook | |
48 | CREATE_USER_HOOK = _create_user_hook |
|
51 | CREATE_USER_HOOK = _create_user_hook | |
@@ -55,6 +58,7 b' PULL_HOOK = _pull_hook' | |||||
55 | CREATE_PULL_REQUEST = _create_pull_request_hook |
|
58 | CREATE_PULL_REQUEST = _create_pull_request_hook | |
56 | REVIEW_PULL_REQUEST = _review_pull_request_hook |
|
59 | REVIEW_PULL_REQUEST = _review_pull_request_hook | |
57 | COMMENT_PULL_REQUEST = _comment_pull_request_hook |
|
60 | COMMENT_PULL_REQUEST = _comment_pull_request_hook | |
|
61 | COMMENT_EDIT_PULL_REQUEST = _comment_edit_pull_request_hook | |||
58 | UPDATE_PULL_REQUEST = _update_pull_request_hook |
|
62 | UPDATE_PULL_REQUEST = _update_pull_request_hook | |
59 | MERGE_PULL_REQUEST = _merge_pull_request_hook |
|
63 | MERGE_PULL_REQUEST = _merge_pull_request_hook | |
60 | CLOSE_PULL_REQUEST = _close_pull_request_hook |
|
64 | CLOSE_PULL_REQUEST = _close_pull_request_hook |
@@ -83,6 +83,33 b' def _comment_commit_repo_hook(*args, **k' | |||||
83 |
|
83 | |||
84 |
|
84 | |||
85 | @has_kwargs({ |
|
85 | @has_kwargs({ | |
|
86 | 'repo_name': '', | |||
|
87 | 'repo_type': '', | |||
|
88 | 'description': '', | |||
|
89 | 'private': '', | |||
|
90 | 'created_on': '', | |||
|
91 | 'enable_downloads': '', | |||
|
92 | 'repo_id': '', | |||
|
93 | 'user_id': '', | |||
|
94 | 'enable_statistics': '', | |||
|
95 | 'clone_uri': '', | |||
|
96 | 'fork_id': '', | |||
|
97 | 'group_id': '', | |||
|
98 | 'created_by': '', | |||
|
99 | 'repository': '', | |||
|
100 | 'comment': '', | |||
|
101 | 'commit': '' | |||
|
102 | }) | |||
|
103 | def _comment_edit_commit_repo_hook(*args, **kwargs): | |||
|
104 | """ | |||
|
105 | POST CREATE REPOSITORY COMMENT ON COMMIT HOOK. This function will be executed after | |||
|
106 | a comment is made on this repository commit. | |||
|
107 | ||||
|
108 | """ | |||
|
109 | return HookResponse(0, '') | |||
|
110 | ||||
|
111 | ||||
|
112 | @has_kwargs({ | |||
86 | 'group_name': '', |
|
113 | 'group_name': '', | |
87 | 'group_parent_id': '', |
|
114 | 'group_parent_id': '', | |
88 | 'group_description': '', |
|
115 | 'group_description': '', | |
@@ -408,6 +435,38 b' def _comment_pull_request_hook(*args, **' | |||||
408 | 'scm': 'type of version control "git", "hg", "svn"', |
|
435 | 'scm': 'type of version control "git", "hg", "svn"', | |
409 | 'username': 'username of actor who triggered this event', |
|
436 | 'username': 'username of actor who triggered this event', | |
410 | 'ip': 'ip address of actor who triggered this hook', |
|
437 | 'ip': 'ip address of actor who triggered this hook', | |
|
438 | ||||
|
439 | 'action': '', | |||
|
440 | 'repository': 'repository name', | |||
|
441 | 'pull_request_id': '', | |||
|
442 | 'url': '', | |||
|
443 | 'title': '', | |||
|
444 | 'description': '', | |||
|
445 | 'status': '', | |||
|
446 | 'comment': '', | |||
|
447 | 'created_on': '', | |||
|
448 | 'updated_on': '', | |||
|
449 | 'commit_ids': '', | |||
|
450 | 'review_status': '', | |||
|
451 | 'mergeable': '', | |||
|
452 | 'source': '', | |||
|
453 | 'target': '', | |||
|
454 | 'author': '', | |||
|
455 | 'reviewers': '', | |||
|
456 | }) | |||
|
457 | def _comment_edit_pull_request_hook(*args, **kwargs): | |||
|
458 | """ | |||
|
459 | This hook will be executed after comment is made on a pull request | |||
|
460 | """ | |||
|
461 | return HookResponse(0, '') | |||
|
462 | ||||
|
463 | ||||
|
464 | @has_kwargs({ | |||
|
465 | 'server_url': 'url of instance that triggered this hook', | |||
|
466 | 'config': 'path to .ini config used', | |||
|
467 | 'scm': 'type of version control "git", "hg", "svn"', | |||
|
468 | 'username': 'username of actor who triggered this event', | |||
|
469 | 'ip': 'ip address of actor who triggered this hook', | |||
411 | 'action': '', |
|
470 | 'action': '', | |
412 | 'repository': 'repository name', |
|
471 | 'repository': 'repository name', | |
413 | 'pull_request_id': '', |
|
472 | 'pull_request_id': '', |
@@ -33,7 +33,7 b' from pyramid_mailer.message import Messa' | |||||
33 | import rhodecode |
|
33 | import rhodecode | |
34 | from rhodecode.lib import audit_logger |
|
34 | from rhodecode.lib import audit_logger | |
35 | from rhodecode.lib.celerylib import get_logger, async_task, RequestContextTask |
|
35 | from rhodecode.lib.celerylib import get_logger, async_task, RequestContextTask | |
36 | from rhodecode.lib.hooks_base import log_create_repository |
|
36 | from rhodecode.lib import hooks_base | |
37 | from rhodecode.lib.utils2 import safe_int, str2bool |
|
37 | from rhodecode.lib.utils2 import safe_int, str2bool | |
38 | from rhodecode.model.db import ( |
|
38 | from rhodecode.model.db import ( | |
39 | Session, IntegrityError, true, Repository, RepoGroup, User) |
|
39 | Session, IntegrityError, true, Repository, RepoGroup, User) | |
@@ -187,7 +187,7 b' def create_repo(form_data, cur_user):' | |||||
187 | clone_uri=clone_uri, |
|
187 | clone_uri=clone_uri, | |
188 | ) |
|
188 | ) | |
189 | repo = Repository.get_by_repo_name(repo_name_full) |
|
189 | repo = Repository.get_by_repo_name(repo_name_full) | |
190 |
|
|
190 | hooks_base.create_repository(created_by=owner.username, **repo.get_dict()) | |
191 |
|
191 | |||
192 | # update repo commit caches initially |
|
192 | # update repo commit caches initially | |
193 | repo.update_commit_cache() |
|
193 | repo.update_commit_cache() | |
@@ -273,7 +273,7 b' def create_repo_fork(form_data, cur_user' | |||||
273 | clone_uri=source_repo_path, |
|
273 | clone_uri=source_repo_path, | |
274 | ) |
|
274 | ) | |
275 | repo = Repository.get_by_repo_name(repo_name_full) |
|
275 | repo = Repository.get_by_repo_name(repo_name_full) | |
276 |
|
|
276 | hooks_base.create_repository(created_by=owner.username, **repo.get_dict()) | |
277 |
|
277 | |||
278 | # update repo commit caches initially |
|
278 | # update repo commit caches initially | |
279 | config = repo._config |
|
279 | config = repo._config |
@@ -400,7 +400,7 b' pre_create_user = ExtensionCallback(' | |||||
400 | 'admin', 'created_by')) |
|
400 | 'admin', 'created_by')) | |
401 |
|
401 | |||
402 |
|
402 | |||
403 |
|
|
403 | create_pull_request = ExtensionCallback( | |
404 | hook_name='CREATE_PULL_REQUEST', |
|
404 | hook_name='CREATE_PULL_REQUEST', | |
405 | kwargs_keys=( |
|
405 | kwargs_keys=( | |
406 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', |
|
406 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', | |
@@ -409,7 +409,7 b' log_create_pull_request = ExtensionCallb' | |||||
409 | 'mergeable', 'source', 'target', 'author', 'reviewers')) |
|
409 | 'mergeable', 'source', 'target', 'author', 'reviewers')) | |
410 |
|
410 | |||
411 |
|
411 | |||
412 |
|
|
412 | merge_pull_request = ExtensionCallback( | |
413 | hook_name='MERGE_PULL_REQUEST', |
|
413 | hook_name='MERGE_PULL_REQUEST', | |
414 | kwargs_keys=( |
|
414 | kwargs_keys=( | |
415 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', |
|
415 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', | |
@@ -418,7 +418,7 b' log_merge_pull_request = ExtensionCallba' | |||||
418 | 'mergeable', 'source', 'target', 'author', 'reviewers')) |
|
418 | 'mergeable', 'source', 'target', 'author', 'reviewers')) | |
419 |
|
419 | |||
420 |
|
420 | |||
421 |
|
|
421 | close_pull_request = ExtensionCallback( | |
422 | hook_name='CLOSE_PULL_REQUEST', |
|
422 | hook_name='CLOSE_PULL_REQUEST', | |
423 | kwargs_keys=( |
|
423 | kwargs_keys=( | |
424 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', |
|
424 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', | |
@@ -427,7 +427,7 b' log_close_pull_request = ExtensionCallba' | |||||
427 | 'mergeable', 'source', 'target', 'author', 'reviewers')) |
|
427 | 'mergeable', 'source', 'target', 'author', 'reviewers')) | |
428 |
|
428 | |||
429 |
|
429 | |||
430 |
|
|
430 | review_pull_request = ExtensionCallback( | |
431 | hook_name='REVIEW_PULL_REQUEST', |
|
431 | hook_name='REVIEW_PULL_REQUEST', | |
432 | kwargs_keys=( |
|
432 | kwargs_keys=( | |
433 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', |
|
433 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', | |
@@ -436,7 +436,7 b' log_review_pull_request = ExtensionCallb' | |||||
436 | 'mergeable', 'source', 'target', 'author', 'reviewers')) |
|
436 | 'mergeable', 'source', 'target', 'author', 'reviewers')) | |
437 |
|
437 | |||
438 |
|
438 | |||
439 |
|
|
439 | comment_pull_request = ExtensionCallback( | |
440 | hook_name='COMMENT_PULL_REQUEST', |
|
440 | hook_name='COMMENT_PULL_REQUEST', | |
441 | kwargs_keys=( |
|
441 | kwargs_keys=( | |
442 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', |
|
442 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', | |
@@ -445,7 +445,16 b' log_comment_pull_request = ExtensionCall' | |||||
445 | 'mergeable', 'source', 'target', 'author', 'reviewers')) |
|
445 | 'mergeable', 'source', 'target', 'author', 'reviewers')) | |
446 |
|
446 | |||
447 |
|
447 | |||
448 |
|
|
448 | comment_edit_pull_request = ExtensionCallback( | |
|
449 | hook_name='COMMENT_EDIT_PULL_REQUEST', | |||
|
450 | kwargs_keys=( | |||
|
451 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', | |||
|
452 | 'repository', 'pull_request_id', 'url', 'title', 'description', | |||
|
453 | 'status', 'comment', 'created_on', 'updated_on', 'commit_ids', 'review_status', | |||
|
454 | 'mergeable', 'source', 'target', 'author', 'reviewers')) | |||
|
455 | ||||
|
456 | ||||
|
457 | update_pull_request = ExtensionCallback( | |||
449 | hook_name='UPDATE_PULL_REQUEST', |
|
458 | hook_name='UPDATE_PULL_REQUEST', | |
450 | kwargs_keys=( |
|
459 | kwargs_keys=( | |
451 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', |
|
460 | 'server_url', 'config', 'scm', 'username', 'ip', 'action', | |
@@ -454,7 +463,7 b' log_update_pull_request = ExtensionCallb' | |||||
454 | 'mergeable', 'source', 'target', 'author', 'reviewers')) |
|
463 | 'mergeable', 'source', 'target', 'author', 'reviewers')) | |
455 |
|
464 | |||
456 |
|
465 | |||
457 |
|
|
466 | create_user = ExtensionCallback( | |
458 | hook_name='CREATE_USER_HOOK', |
|
467 | hook_name='CREATE_USER_HOOK', | |
459 | kwargs_keys=( |
|
468 | kwargs_keys=( | |
460 | 'username', 'full_name_or_username', 'full_contact', 'user_id', |
|
469 | 'username', 'full_name_or_username', 'full_contact', 'user_id', | |
@@ -465,7 +474,7 b' log_create_user = ExtensionCallback(' | |||||
465 | 'inherit_default_permissions', 'created_by', 'created_on')) |
|
474 | 'inherit_default_permissions', 'created_by', 'created_on')) | |
466 |
|
475 | |||
467 |
|
476 | |||
468 |
|
|
477 | delete_user = ExtensionCallback( | |
469 | hook_name='DELETE_USER_HOOK', |
|
478 | hook_name='DELETE_USER_HOOK', | |
470 | kwargs_keys=( |
|
479 | kwargs_keys=( | |
471 | 'username', 'full_name_or_username', 'full_contact', 'user_id', |
|
480 | 'username', 'full_name_or_username', 'full_contact', 'user_id', | |
@@ -476,7 +485,7 b' log_delete_user = ExtensionCallback(' | |||||
476 | 'inherit_default_permissions', 'deleted_by')) |
|
485 | 'inherit_default_permissions', 'deleted_by')) | |
477 |
|
486 | |||
478 |
|
487 | |||
479 |
|
|
488 | create_repository = ExtensionCallback( | |
480 | hook_name='CREATE_REPO_HOOK', |
|
489 | hook_name='CREATE_REPO_HOOK', | |
481 | kwargs_keys=( |
|
490 | kwargs_keys=( | |
482 | 'repo_name', 'repo_type', 'description', 'private', 'created_on', |
|
491 | 'repo_name', 'repo_type', 'description', 'private', 'created_on', | |
@@ -484,7 +493,7 b' log_create_repository = ExtensionCallbac' | |||||
484 | 'clone_uri', 'fork_id', 'group_id', 'created_by')) |
|
493 | 'clone_uri', 'fork_id', 'group_id', 'created_by')) | |
485 |
|
494 | |||
486 |
|
495 | |||
487 |
|
|
496 | delete_repository = ExtensionCallback( | |
488 | hook_name='DELETE_REPO_HOOK', |
|
497 | hook_name='DELETE_REPO_HOOK', | |
489 | kwargs_keys=( |
|
498 | kwargs_keys=( | |
490 | 'repo_name', 'repo_type', 'description', 'private', 'created_on', |
|
499 | 'repo_name', 'repo_type', 'description', 'private', 'created_on', | |
@@ -492,7 +501,7 b' log_delete_repository = ExtensionCallbac' | |||||
492 | 'clone_uri', 'fork_id', 'group_id', 'deleted_by', 'deleted_on')) |
|
501 | 'clone_uri', 'fork_id', 'group_id', 'deleted_by', 'deleted_on')) | |
493 |
|
502 | |||
494 |
|
503 | |||
495 |
|
|
504 | comment_commit_repository = ExtensionCallback( | |
496 | hook_name='COMMENT_COMMIT_REPO_HOOK', |
|
505 | hook_name='COMMENT_COMMIT_REPO_HOOK', | |
497 | kwargs_keys=( |
|
506 | kwargs_keys=( | |
498 | 'repo_name', 'repo_type', 'description', 'private', 'created_on', |
|
507 | 'repo_name', 'repo_type', 'description', 'private', 'created_on', | |
@@ -500,8 +509,16 b' log_comment_commit_repository = Extensio' | |||||
500 | 'clone_uri', 'fork_id', 'group_id', |
|
509 | 'clone_uri', 'fork_id', 'group_id', | |
501 | 'repository', 'created_by', 'comment', 'commit')) |
|
510 | 'repository', 'created_by', 'comment', 'commit')) | |
502 |
|
511 | |||
|
512 | comment_edit_commit_repository = ExtensionCallback( | |||
|
513 | hook_name='COMMENT_EDIT_COMMIT_REPO_HOOK', | |||
|
514 | kwargs_keys=( | |||
|
515 | 'repo_name', 'repo_type', 'description', 'private', 'created_on', | |||
|
516 | 'enable_downloads', 'repo_id', 'user_id', 'enable_statistics', | |||
|
517 | 'clone_uri', 'fork_id', 'group_id', | |||
|
518 | 'repository', 'created_by', 'comment', 'commit')) | |||
503 |
|
519 | |||
504 | log_create_repository_group = ExtensionCallback( |
|
520 | ||
|
521 | create_repository_group = ExtensionCallback( | |||
505 | hook_name='CREATE_REPO_GROUP_HOOK', |
|
522 | hook_name='CREATE_REPO_GROUP_HOOK', | |
506 | kwargs_keys=( |
|
523 | kwargs_keys=( | |
507 | 'group_name', 'group_parent_id', 'group_description', |
|
524 | 'group_name', 'group_parent_id', 'group_description', |
@@ -94,7 +94,7 b' def trigger_comment_commit_hooks(usernam' | |||||
94 | extras.commit = commit.serialize() |
|
94 | extras.commit = commit.serialize() | |
95 | extras.comment = comment.get_api_data() |
|
95 | extras.comment = comment.get_api_data() | |
96 | extras.created_by = username |
|
96 | extras.created_by = username | |
97 |
hooks_base. |
|
97 | hooks_base.comment_commit_repository(**extras) | |
98 |
|
98 | |||
99 |
|
99 | |||
100 | def trigger_comment_commit_edit_hooks(username, repo_name, repo_type, repo, data=None): |
|
100 | def trigger_comment_commit_edit_hooks(username, repo_name, repo_type, repo, data=None): | |
@@ -121,8 +121,7 b' def trigger_comment_commit_edit_hooks(us' | |||||
121 | extras.commit = commit.serialize() |
|
121 | extras.commit = commit.serialize() | |
122 | extras.comment = comment.get_api_data() |
|
122 | extras.comment = comment.get_api_data() | |
123 | extras.created_by = username |
|
123 | extras.created_by = username | |
124 | # TODO(marcink): rcextensions handlers ?? |
|
124 | hooks_base.comment_edit_commit_repository(**extras) | |
125 | hooks_base.log_comment_commit_repository(**extras) |
|
|||
126 |
|
125 | |||
127 |
|
126 | |||
128 | def trigger_create_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): |
|
127 | def trigger_create_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): | |
@@ -141,7 +140,7 b' def trigger_create_pull_request_hook(use' | |||||
141 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'create_pull_request') |
|
140 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'create_pull_request') | |
142 | events.trigger(events.PullRequestCreateEvent(pull_request)) |
|
141 | events.trigger(events.PullRequestCreateEvent(pull_request)) | |
143 | extras.update(pull_request.get_api_data(with_merge_state=False)) |
|
142 | extras.update(pull_request.get_api_data(with_merge_state=False)) | |
144 |
hooks_base. |
|
143 | hooks_base.create_pull_request(**extras) | |
145 |
|
144 | |||
146 |
|
145 | |||
147 | def trigger_merge_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): |
|
146 | def trigger_merge_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): | |
@@ -160,7 +159,7 b' def trigger_merge_pull_request_hook(user' | |||||
160 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'merge_pull_request') |
|
159 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'merge_pull_request') | |
161 | events.trigger(events.PullRequestMergeEvent(pull_request)) |
|
160 | events.trigger(events.PullRequestMergeEvent(pull_request)) | |
162 | extras.update(pull_request.get_api_data()) |
|
161 | extras.update(pull_request.get_api_data()) | |
163 |
hooks_base. |
|
162 | hooks_base.merge_pull_request(**extras) | |
164 |
|
163 | |||
165 |
|
164 | |||
166 | def trigger_close_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): |
|
165 | def trigger_close_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): | |
@@ -179,7 +178,7 b' def trigger_close_pull_request_hook(user' | |||||
179 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'close_pull_request') |
|
178 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'close_pull_request') | |
180 | events.trigger(events.PullRequestCloseEvent(pull_request)) |
|
179 | events.trigger(events.PullRequestCloseEvent(pull_request)) | |
181 | extras.update(pull_request.get_api_data()) |
|
180 | extras.update(pull_request.get_api_data()) | |
182 |
hooks_base. |
|
181 | hooks_base.close_pull_request(**extras) | |
183 |
|
182 | |||
184 |
|
183 | |||
185 | def trigger_review_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): |
|
184 | def trigger_review_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): | |
@@ -199,7 +198,7 b' def trigger_review_pull_request_hook(use' | |||||
199 | status = data.get('status') |
|
198 | status = data.get('status') | |
200 | events.trigger(events.PullRequestReviewEvent(pull_request, status)) |
|
199 | events.trigger(events.PullRequestReviewEvent(pull_request, status)) | |
201 | extras.update(pull_request.get_api_data()) |
|
200 | extras.update(pull_request.get_api_data()) | |
202 |
hooks_base. |
|
201 | hooks_base.review_pull_request(**extras) | |
203 |
|
202 | |||
204 |
|
203 | |||
205 | def trigger_comment_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): |
|
204 | def trigger_comment_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): | |
@@ -221,7 +220,7 b' def trigger_comment_pull_request_hook(us' | |||||
221 | events.trigger(events.PullRequestCommentEvent(pull_request, comment)) |
|
220 | events.trigger(events.PullRequestCommentEvent(pull_request, comment)) | |
222 | extras.update(pull_request.get_api_data()) |
|
221 | extras.update(pull_request.get_api_data()) | |
223 | extras.comment = comment.get_api_data() |
|
222 | extras.comment = comment.get_api_data() | |
224 |
hooks_base. |
|
223 | hooks_base.comment_pull_request(**extras) | |
225 |
|
224 | |||
226 |
|
225 | |||
227 | def trigger_comment_pull_request_edit_hook(username, repo_name, repo_type, pull_request, data=None): |
|
226 | def trigger_comment_pull_request_edit_hook(username, repo_name, repo_type, pull_request, data=None): | |
@@ -243,8 +242,7 b' def trigger_comment_pull_request_edit_ho' | |||||
243 | events.trigger(events.PullRequestCommentEditEvent(pull_request, comment)) |
|
242 | events.trigger(events.PullRequestCommentEditEvent(pull_request, comment)) | |
244 | extras.update(pull_request.get_api_data()) |
|
243 | extras.update(pull_request.get_api_data()) | |
245 | extras.comment = comment.get_api_data() |
|
244 | extras.comment = comment.get_api_data() | |
246 | # TODO(marcink): handle rcextensions... |
|
245 | hooks_base.comment_edit_pull_request(**extras) | |
247 | hooks_base.log_comment_pull_request(**extras) |
|
|||
248 |
|
246 | |||
249 |
|
247 | |||
250 | def trigger_update_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): |
|
248 | def trigger_update_pull_request_hook(username, repo_name, repo_type, pull_request, data=None): | |
@@ -263,4 +261,4 b' def trigger_update_pull_request_hook(use' | |||||
263 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'update_pull_request') |
|
261 | extras = _get_vcs_operation_context(username, repo_name, repo_type, 'update_pull_request') | |
264 | events.trigger(events.PullRequestUpdateEvent(pull_request)) |
|
262 | events.trigger(events.PullRequestUpdateEvent(pull_request)) | |
265 | extras.update(pull_request.get_api_data()) |
|
263 | extras.update(pull_request.get_api_data()) | |
266 |
hooks_base. |
|
264 | hooks_base.update_pull_request(**extras) |
@@ -33,7 +33,7 b' from rhodecode import events' | |||||
33 | from rhodecode.lib.auth import HasUserGroupPermissionAny |
|
33 | from rhodecode.lib.auth import HasUserGroupPermissionAny | |
34 | from rhodecode.lib.caching_query import FromCache |
|
34 | from rhodecode.lib.caching_query import FromCache | |
35 | from rhodecode.lib.exceptions import AttachedForksError, AttachedPullRequestsError |
|
35 | from rhodecode.lib.exceptions import AttachedForksError, AttachedPullRequestsError | |
36 | from rhodecode.lib.hooks_base import log_delete_repository |
|
36 | from rhodecode.lib import hooks_base | |
37 | from rhodecode.lib.user_log_filter import user_log_filter |
|
37 | from rhodecode.lib.user_log_filter import user_log_filter | |
38 | from rhodecode.lib.utils import make_db_config |
|
38 | from rhodecode.lib.utils import make_db_config | |
39 | from rhodecode.lib.utils2 import ( |
|
39 | from rhodecode.lib.utils2 import ( | |
@@ -767,7 +767,7 b' class RepoModel(BaseModel):' | |||||
767 | 'deleted_by': cur_user, |
|
767 | 'deleted_by': cur_user, | |
768 | 'deleted_on': time.time(), |
|
768 | 'deleted_on': time.time(), | |
769 | }) |
|
769 | }) | |
770 |
|
|
770 | hooks_base.delete_repository(**old_repo_dict) | |
771 | events.trigger(events.RepoDeleteEvent(repo)) |
|
771 | events.trigger(events.RepoDeleteEvent(repo)) | |
772 | except Exception: |
|
772 | except Exception: | |
773 | log.error(traceback.format_exc()) |
|
773 | log.error(traceback.format_exc()) |
@@ -308,13 +308,13 b' class RepoGroupModel(BaseModel):' | |||||
308 | self._create_group(new_repo_group.group_name) |
|
308 | self._create_group(new_repo_group.group_name) | |
309 |
|
309 | |||
310 | # trigger the post hook |
|
310 | # trigger the post hook | |
311 |
from rhodecode.lib |
|
311 | from rhodecode.lib import hooks_base | |
312 | repo_group = RepoGroup.get_by_group_name(group_name) |
|
312 | repo_group = RepoGroup.get_by_group_name(group_name) | |
313 |
|
313 | |||
314 | # update repo group commit caches initially |
|
314 | # update repo group commit caches initially | |
315 | repo_group.update_commit_cache() |
|
315 | repo_group.update_commit_cache() | |
316 |
|
316 | |||
317 |
|
|
317 | hooks_base.create_repository_group( | |
318 | created_by=user.username, **repo_group.get_dict()) |
|
318 | created_by=user.username, **repo_group.get_dict()) | |
319 |
|
319 | |||
320 | # Trigger create event. |
|
320 | # Trigger create event. |
@@ -262,8 +262,7 b' class UserModel(BaseModel):' | |||||
262 |
|
262 | |||
263 | from rhodecode.lib.auth import ( |
|
263 | from rhodecode.lib.auth import ( | |
264 | get_crypt_password, check_password) |
|
264 | get_crypt_password, check_password) | |
265 |
from rhodecode.lib |
|
265 | from rhodecode.lib import hooks_base | |
266 | log_create_user, check_allowed_create_user) |
|
|||
267 |
|
266 | |||
268 | def _password_change(new_user, password): |
|
267 | def _password_change(new_user, password): | |
269 | old_password = new_user.password or '' |
|
268 | old_password = new_user.password or '' | |
@@ -327,7 +326,7 b' class UserModel(BaseModel):' | |||||
327 | if new_active_user and strict_creation_check: |
|
326 | if new_active_user and strict_creation_check: | |
328 | # raises UserCreationError if it's not allowed for any reason to |
|
327 | # raises UserCreationError if it's not allowed for any reason to | |
329 | # create new active user, this also executes pre-create hooks |
|
328 | # create new active user, this also executes pre-create hooks | |
330 | check_allowed_create_user(user_data, cur_user, strict_check=True) |
|
329 | hooks_base.check_allowed_create_user(user_data, cur_user, strict_check=True) | |
331 | events.trigger(events.UserPreCreate(user_data)) |
|
330 | events.trigger(events.UserPreCreate(user_data)) | |
332 | new_user = User() |
|
331 | new_user = User() | |
333 | edit = False |
|
332 | edit = False | |
@@ -390,7 +389,7 b' class UserModel(BaseModel):' | |||||
390 | kwargs = new_user.get_dict() |
|
389 | kwargs = new_user.get_dict() | |
391 | # backward compat, require api_keys present |
|
390 | # backward compat, require api_keys present | |
392 | kwargs['api_keys'] = kwargs['auth_tokens'] |
|
391 | kwargs['api_keys'] = kwargs['auth_tokens'] | |
393 |
|
|
392 | hooks_base.create_user(created_by=cur_user, **kwargs) | |
394 | events.trigger(events.UserPostCreate(user_data)) |
|
393 | events.trigger(events.UserPostCreate(user_data)) | |
395 | return new_user |
|
394 | return new_user | |
396 | except (DatabaseError,): |
|
395 | except (DatabaseError,): | |
@@ -569,7 +568,7 b' class UserModel(BaseModel):' | |||||
569 | def delete(self, user, cur_user=None, handle_repos=None, |
|
568 | def delete(self, user, cur_user=None, handle_repos=None, | |
570 | handle_repo_groups=None, handle_user_groups=None, |
|
569 | handle_repo_groups=None, handle_user_groups=None, | |
571 | handle_pull_requests=None, handle_artifacts=None, handle_new_owner=None): |
|
570 | handle_pull_requests=None, handle_artifacts=None, handle_new_owner=None): | |
572 |
from rhodecode.lib |
|
571 | from rhodecode.lib import hooks_base | |
573 |
|
572 | |||
574 | if not cur_user: |
|
573 | if not cur_user: | |
575 | cur_user = getattr(get_current_rhodecode_user(), 'username', None) |
|
574 | cur_user = getattr(get_current_rhodecode_user(), 'username', None) | |
@@ -638,7 +637,7 b' class UserModel(BaseModel):' | |||||
638 | self.sa.expire(user) |
|
637 | self.sa.expire(user) | |
639 | self.sa.delete(user) |
|
638 | self.sa.delete(user) | |
640 |
|
639 | |||
641 |
|
|
640 | hooks_base.delete_user(deleted_by=cur_user, **user_data) | |
642 | except Exception: |
|
641 | except Exception: | |
643 | log.error(traceback.format_exc()) |
|
642 | log.error(traceback.format_exc()) | |
644 | raise |
|
643 | raise |
General Comments 0
You need to be logged in to leave comments.
Login now