def make_tag(self, name, obj): tag = make_object(Tag, name=name, message='', tag_time=12345, tag_timezone=0, tagger='Test Tagger <*****@*****.**>', object=(object_class(obj.type_name), obj.id)) self.store.add_object(tag) return tag
def assert_copy(self, orig): oclass = object_class(orig.type_num) copy = orig.copy() self.assertTrue(isinstance(copy, oclass)) self.assertEqual(copy, orig) self.assertTrue(copy is not orig)
def peel_sha(self, sha): """Peel all tags from a SHA. :param sha: The object SHA to peel. :return: The fully-peeled SHA1 of a tag object, after peeling all intermediate tags; if the original ref does not point to a tag, this will equal the original SHA1. """ obj = self[sha] obj_class = object_class(obj.type_name) while obj_class is Tag: obj_class, sha = obj.object obj = self[sha] return obj
def get_peeled(self, ref): """Get the peeled value of a ref. :param ref: the refname to peel :return: the fully-peeled SHA1 of a tag object, after peeling all intermediate tags; if the original ref does not point to a tag, this will equal the original SHA1. """ cached = self.refs.get_peeled(ref) if cached is not None: return cached obj = self[ref] obj_class = object_class(obj.type_name) while obj_class is Tag: obj_class, sha = obj.object obj = self.get_object(sha) return obj.id
def make_tag(target, **attrs): """Make a Tag object with a default set of values. :param target: object to be tagged (Commit, Blob, Tree, etc) :param attrs: dict of attributes to overwrite from the default values. :return: A newly initialized Tag object. """ target_id = target.id target_type = object_class(target.type_name) default_time = int(time.mktime(datetime.datetime(2010, 1, 1).timetuple())) all_attrs = {'tagger': b'Test Author <*****@*****.**>', 'tag_time': default_time, 'tag_timezone': 0, 'message': b'Test message.', 'object': (target_type, target_id), 'name': b'Test Tag', } all_attrs.update(attrs) return make_object(Tag, **all_attrs)
def make_tag(target, **attrs): """Make a Tag object with a default set of values. Args: target: object to be tagged (Commit, Blob, Tree, etc) attrs: dict of attributes to overwrite from the default values. Returns: A newly initialized Tag object. """ target_id = target.id target_type = object_class(target.type_name) default_time = int(time.mktime(datetime.datetime(2010, 1, 1).timetuple())) all_attrs = { "tagger": b"Test Author <*****@*****.**>", "tag_time": default_time, "tag_timezone": 0, "message": b"Test message.", "object": (target_type, target_id), "name": b"Test Tag", } all_attrs.update(attrs) return make_object(Tag, **all_attrs)