Changeset - 8390da12aa16
[Not reviewed]
default
0 2 0
domruf - 9 years ago 2017-05-11 20:09:25
dominikruf@gmail.com
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.
2 files changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/model/scm.py
Show inline comments
 
@@ -381,28 +381,28 @@ class ScmModel(object):
 
            from kallithea.lib.vcs.backends.hg import MercurialInMemoryChangeset
 
            return MercurialInMemoryChangeset
 

	
 
        if scm_type == 'git':
 
            from kallithea.lib.vcs.backends.git import GitInMemoryChangeset
 
            return GitInMemoryChangeset
 

	
 
        raise Exception('Invalid scm_type, must be one of hg,git got %s'
 
                        % (scm_type,))
 

	
 
    def pull_changes(self, repo, username):
 
        """
 
        Pull from "clone URL".
 
        Pull from "clone URL" or fork origin.
 
        """
 
        dbrepo = self.__get_repo(repo)
 
        clone_uri = dbrepo.clone_uri
 
        clone_uri = dbrepo.clone_uri or dbrepo.fork and dbrepo.fork.repo_full_path
 
        if not clone_uri:
 
            raise Exception("This repository doesn't have a clone uri")
 

	
 
        repo = dbrepo.scm_instance
 
        repo_name = dbrepo.repo_name
 
        try:
 
            if repo.alias == 'git':
 
                repo.fetch(clone_uri)
 
                # git doesn't really have something like post-fetch action
 
                # we fake that now. #TODO: extract fetched revisions somehow
 
                # here
 
                self._handle_push(repo,
kallithea/templates/admin/repos/repo_edit_remote.html
Show inline comments
 
%if c.repo_info.clone_uri:
 
%if c.repo_info.clone_uri or c.repo_info.fork:
 
<h4>
 
   ${_('Remote repository URL')}: <a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri_hidden}</a>
 
  %if c.repo_info.fork:
 
    ${_('Fork of repository')}:
 
    <a href="${h.url('summary_home',repo_name=c.repo_info.fork.repo_name)}">${c.repo_info.fork.repo_name}</a>
 
  %else:
 
    ${_('Remote repository URL')}:
 
    <a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri_hidden}</a>
 
  %endif
 
</h4>
 
${h.form(url('edit_repo_remote_update', repo_name=c.repo_name))}
 
<div class="form">
 
    <div>
 
        ${h.submit('remote_pull_%s' % c.repo_info.repo_name,
 
            _('Pull Changes from Remote Repository'),
 
            class_="btn btn-default btn-sm",
 
            onclick="return confirm('"+_('Confirm to pull changes from remote repository.')+"');")}
 
    </div>
 
</div>
 
${h.end_form()}
 
%else:
0 comments (0 inline, 0 general)