You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/04/01 23:10:34 UTC

[17/45] allura git commit: [#7830] ticket:744 Change author and message for merge commit

[#7830] ticket:744 Change author and message for merge commit


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e146bbe8
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e146bbe8
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e146bbe8

Branch: refs/heads/hss/7072
Commit: e146bbe899ffa1673ec540a7cd7a16a97a68457e
Parents: 8874219
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Mar 6 11:24:08 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:30 2015 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py              | 10 +++++++++-
 ForgeGit/forgegit/tests/model/test_repository.py | 13 +++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e146bbe8/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 62e0604..8841f52 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -123,7 +123,15 @@ class Repository(M.Repository):
         tmp_repo.git.fetch('origin', mr.target_branch)
         tmp_repo.git.checkout(mr.target_branch)
         tmp_repo.git.fetch(mr.downstream_repo.full_fs_path, mr.source_branch)
-        tmp_repo.git.merge(mr.downstream.commit_id)
+        author = h.really_unicode(c.user.display_name or c.user.username)
+        tmp_repo.git.config('user.name', author)
+        tmp_repo.git.config('user.email', '')
+        msg = u'Merge {} branch {} into {}\n\n{}'.format(
+            mr.downstream_repo.url(),
+            mr.source_branch,
+            mr.target_branch,
+            h.absurl(mr.url()))
+        tmp_repo.git.merge(mr.downstream.commit_id, '-m', msg)
         tmp_repo.git.push('origin', mr.target_branch)
         shutil.rmtree(tmp_path, ignore_errors=True)
 

http://git-wip-us.apache.org/repos/asf/allura/blob/e146bbe8/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 325a6ea..a9de6ba 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -615,9 +615,12 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
     @mock.patch('forgegit.model.git_repo.GitImplementation', autospec=True)
     @mock.patch('forgegit.model.git_repo.shutil', autospec=True)
     def test_merge(self, shutil, GitImplementation, git, tempfile):
-        mr = mock.Mock(downstream_repo=Object(full_fs_path='downstream-url'),
+        mr = mock.Mock(downstream_repo=mock.Mock(
+                           full_fs_path='downstream-url',
+                           url=lambda: 'downstream-repo-url'),
                        source_branch='source-branch',
                        target_branch='target-branch',
+                       url=lambda: '/merge-request/1/',
                        downstream=mock.Mock(commit_id='cid'))
         _git = mock.Mock()
         self.repo._impl._git.git = _git
@@ -632,7 +635,13 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             [mock.call('origin', 'target-branch'),
              mock.call('downstream-url', 'source-branch')])
         tmp_repo.git.checkout.assert_called_once_with('target-branch')
-        tmp_repo.git.merge.assert_called_once_with('cid')
+        assert_equal(
+            tmp_repo.git.config.call_args_list,
+            [mock.call('user.name', 'Test Admin'),
+             mock.call('user.email', '')])
+        msg = u'Merge downstream-repo-url branch source-branch into target-branch'
+        msg += u'\n\nhttp://localhost/merge-request/1/'
+        tmp_repo.git.merge.assert_called_once_with('cid', '-m', msg)
         tmp_repo.git.push.assert_called_once_with('origin', 'target-branch')
         shutil.rmtree.assert_called_once_with(
             tempfile.mkdtemp.return_value,