##// END OF EJS Templates
scm-model: add extra validation logic for remote uri to filter out bad scheduler entries.
marcink -
r3071:144eaab4 default
parent child Browse files
Show More
@@ -23,12 +23,9 b' Scm model for RhodeCode'
23 23 """
24 24
25 25 import os.path
26 import re
27 import sys
28 26 import traceback
29 27 import logging
30 28 import cStringIO
31 import pkg_resources
32 29
33 30 from sqlalchemy import func
34 31 from zope.cachedescriptors.property import Lazy as LazyProperty
@@ -53,6 +50,7 b' from rhodecode.model.db import ('
53 50 Repository, CacheKey, UserFollowing, UserLog, User, RepoGroup,
54 51 PullRequest)
55 52 from rhodecode.model.settings import VcsSettingsModel
53 from rhodecode.model.validation_schema.validators import url_validator, InvalidCloneUrl
56 54
57 55 log = logging.getLogger(__name__)
58 56
@@ -386,11 +384,17 b' class ScmModel(BaseModel):'
386 384 raise Exception("This repository doesn't have a clone uri")
387 385
388 386 repo = dbrepo.scm_instance(cache=False)
389 # TODO: marcink fix this an re-enable since we need common logic
390 # for hg/git remove hooks so we don't trigger them on fetching
391 # commits from remote
392 387 repo.config.clear_section('hooks')
393 388
389 try:
390 # NOTE(marcink): add extra validation so we skip invalid urls
391 # this is due this tasks can be executed via scheduler without
392 # proper validation of remote_uri
393 config = make_db_config(clear_session=False)
394 url_validator(remote_uri, dbrepo.repo_type, config)
395 except InvalidCloneUrl:
396 raise
397
394 398 repo_name = dbrepo.repo_name
395 399 try:
396 400 # TODO: we need to make sure those operations call proper hooks !
@@ -411,6 +415,15 b' class ScmModel(BaseModel):'
411 415 repo.config.clear_section('hooks')
412 416
413 417 try:
418 # NOTE(marcink): add extra validation so we skip invalid urls
419 # this is due this tasks can be executed via scheduler without
420 # proper validation of remote_uri
421 config = make_db_config(clear_session=False)
422 url_validator(remote_uri, dbrepo.repo_type, config)
423 except InvalidCloneUrl:
424 raise
425
426 try:
414 427 repo.push(remote_uri)
415 428 except Exception:
416 429 log.error(traceback.format_exc())
General Comments 0
You need to be logged in to leave comments. Login now