|
1 | 1 | import collections |
2 | 2 | import imp |
3 | 3 | import re |
| 4 | +import sys |
4 | 5 | import yaml |
5 | 6 |
|
6 | 7 | from rdopkg import exception |
@@ -91,19 +92,26 @@ def __init__(self, *args, **kwargs): |
91 | 92 | self._info = None |
92 | 93 |
|
93 | 94 | def ensure_rdoinfo(self): |
94 | | - if self.rdoinfo: |
95 | | - return |
| 95 | + # when running get_info with gitrev, we are modifying rdoinfo module |
| 96 | + # while runing rdopkg. This seems to be problematic if we are using |
| 97 | + # the compiled .pyc so i'm forcing to load rdoinfo module from .py |
| 98 | + sys.dont_write_bytecode = True |
96 | 99 | file, path, desc = imp.find_module('rdoinfo', [self.repo_path]) |
97 | 100 | self.rdoinfo = imp.load_module('rdoinfo', file, path, desc) |
| 101 | + sys.dont_write_bytecode = False |
98 | 102 |
|
99 | 103 | def get_info(self, gitrev=None): |
100 | | - self.ensure_rdoinfo() |
101 | 104 | with self.repo_dir(): |
102 | 105 | if gitrev: |
103 | | - infofile = git.get_file_content(gitrev, self.info_file) |
104 | | - info = yaml.load(infofile) |
105 | | - self.rdoinfo.parse_info(info, apply_tag=self.apply_tag) |
| 106 | + commit1 = git.current_commit() |
| 107 | + git('checkout', gitrev, log_cmd=False) |
| 108 | + self.ensure_rdoinfo() |
| 109 | + info = self.rdoinfo.parse_info_file( |
| 110 | + self.info_file, apply_tag=self.apply_tag) |
| 111 | + git('checkout', commit1, log_cmd=False) |
| 112 | + self.ensure_rdoinfo() |
106 | 113 | else: |
| 114 | + self.ensure_rdoinfo() |
107 | 115 | info = self.rdoinfo.parse_info_file( |
108 | 116 | self.info_file, apply_tag=self.apply_tag) |
109 | 117 | return info |
|
0 commit comments