Merge lp:~acsone-openerp/anybox.recipe.openerp/trunk-bug-1234014-lmi into lp:anybox.recipe.openerp

Proposed by Laurent Mignon (Acsone)
Status: Merged
Merged at revision: 524
Proposed branch: lp:~acsone-openerp/anybox.recipe.openerp/trunk-bug-1234014-lmi
Merge into: lp:anybox.recipe.openerp
Diff against target: 59 lines (+32/-0)
2 files modified
anybox/recipe/openerp/vcs/git.py (+14/-0)
anybox/recipe/openerp/vcs/tests/test_git.py (+18/-0)
To merge this branch: bzr merge lp:~acsone-openerp/anybox.recipe.openerp/trunk-bug-1234014-lmi
Reviewer Review Type Date Requested Status
Georges Racinet Pending
Anybox Pending
Review via email: mp+207212@code.launchpad.net

Description of the change

we need to use the command 'git pull' to update a tracked branch

To post a comment you must log in.
514. By Laurent Mignon (Acsone)

[MRG] lp:anybox.recipe.openerp r523

515. By Laurent Mignon (Acsone)

[FIX] lp:1234014 add test to avoid regression

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi Georges,

I finally added the unit test. Without this patch the branches from git are never updated when running the buildout...

Regards,

lmi

Revision history for this message
Georges Racinet (gracinet) wrote :

Test passes for me, I'm merging in trunk and will backport to current stable branch (1.8)
Sorry for being so slow on this one !

I guess we'll use much more Git now :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'anybox/recipe/openerp/vcs/git.py'
2--- anybox/recipe/openerp/vcs/git.py 2013-09-08 21:48:12 +0000
3+++ anybox/recipe/openerp/vcs/git.py 2014-05-23 15:17:21 +0000
4@@ -80,6 +80,12 @@
5 target_dir, revision)
6 self._switch(revision)
7
8+ if self._isATrackedBranch(revision):
9+ if not offline:
10+ logger.info("Pull for git repo %s (rev %s)...",
11+ target_dir, rev_str)
12+ subprocess.check_call(['git', 'pull'])
13+
14 def archive(self, target_path):
15 revision = self.parents()[0]
16 if not os.path.exists(target_path):
17@@ -95,6 +101,14 @@
18 '-C', target_path])
19 os.unlink(target_tar.name)
20
21+ def _isATrackedBranch(self, revision):
22+ rbp = self._remote_branch_prefix
23+ branches = utils.check_output(["git", "branch", "-a"])
24+ branch = revision
25+ return re.search(
26+ "^ " + re.escape(rbp) + "\/" + re.escape(branch) + "$", branches,
27+ re.M)
28+
29 def _needToSwitchRevision(self, revision):
30 """ Check if we need to checkout to an other branch
31 """
32
33=== modified file 'anybox/recipe/openerp/vcs/tests/test_git.py'
34--- anybox/recipe/openerp/vcs/tests/test_git.py 2013-09-15 12:57:12 +0000
35+++ anybox/recipe/openerp/vcs/tests/test_git.py 2014-05-23 15:17:21 +0000
36@@ -137,6 +137,24 @@
37 f.write('mod')
38 self.assertTrue(repo.uncommitted_changes())
39
40+ def test_update_needs_pull(self):
41+ """Update needs to be pulled from target."""
42+ target_dir = os.path.join(self.dst_dir, "clone to update")
43+ repo = GitRepo(target_dir, self.src_repo)
44+ repo('master')
45+
46+ self.assertFalse(repo.uncommitted_changes())
47+
48+ # update the cloned repo
49+ new_sha = git_write_commit(self.src_repo, 'tracked',
50+ "new content", msg="new commit")
51+ # We really don't have the new rev in our clone
52+ self.assertNotEqual(repo.parents(), [new_sha])
53+
54+ # update our clone
55+ repo('master')
56+ self.assertEqual(repo.parents(), [new_sha])
57+
58
59 class GitBranchTestCase(GitBaseTestCase):
60

Subscribers

People subscribed via source and target branches