def parse_gitlab_repository_owner(self, context): raw_payload = context.raw_payload utils = re.search("(https?://.+/)(\w+)/.+", raw_payload["repository"]["git_http_url"]) link = utils.group(1) username = utils.group(2) data = { "name": username.title(), "username": username, "uuid": "", "avatar": "", "url": urljoin(link, username), "email": "", "type": context.type, } if username == raw_payload["user_username"]: data["name"] = raw_payload["user_name"] data["uuid"] = raw_payload["user_id"] data["avatar"] = urljoin(link, raw_payload["user_avatar"]) data["email"] = raw_payload["user_email"] return data
def parse_gitlab_branch(self, context, commits=True): payload = context.raw_payload branch_name = payload["ref"].split('/')[-1] data = { "name": branch_name, "url": urljoin(payload['project']['http_url'], 'tree', branch_name), "type": context.type, "repository_id": context.repository.id } if commits: data["commits"] = self.parse_gitlab_commits(context) return data
def get_repository_owner_data(self): utils = re.search('(https?://.+/)(\w+)/.+', self.data['repository']['git_http_url']) link = utils.group(1) username = utils.group(2) return { 'name': username == self.data['user_username'] and self.data['user_name'] or username.title(), 'username': username, 'uuid': username == self.data['user_username'] and self.data['user_id'] or '', 'avatar': username == self.data['user_username'] and urljoin(link, self.data['user_avatar']), 'url': urljoin(link, username), 'email': username == self.data['user_username'] and self.data['user_email'] or '' }
def parse_gitlab_branch(self, context, commits=True): payload = context.raw_payload branch_name = payload["ref"].split("/")[-1] data = { "name": branch_name, "type": context.type, "repository_id": context.repository.id, "url": urljoin(payload["project"]["homepage"] + "/", "tree", branch_name), } if commits: data["commits"] = self.parse_gitlab_commits(context) return data
def get_branch_data(self, push): branch_name = push["ref"].split('/')[-1] return { "name": branch_name, "url": urljoin(push['project']['http_url'], 'tree', branch_name) }