def diff(self, id, raw=False, file=None): file_args = ['--', file] if file else [] if raw: result = check_output(['git', 'diff', '--raw', id, self.obj.hex] + file_args, cwd=self.repo.path) return _parse_raw_diff(result) else: return check_output(['git', 'diff', id, self.obj.hex] + file_args, cwd=self.repo.path)
def repo_git_http(request, username, repo_name, path): repo = get_repo(request.user, username + "/" + repo_name) grepo = git.Repo.from_model(repo) # PATH_INFO=/ GIT_PROJECT_ROOT=~/lemur/ REQUEST_METHOD=GET env = { "PATH_INFO": path, "GIT_PROJECT_ROOT": grepo.path, "REQUEST_METHOD": request.method, "GIT_HTTP_EXPORT_ALL": "1", } # TODO: QUERY_STRING, REMOTE_USER data = check_output([webapp.settings.GIT_CORE_PATH + "/git-http-backend"], env=env) header_data, response_data = data.split("\r\n\r\n", 1) headers = dict(line.strip().split(":", 1) for line in header_data.splitlines()) response = http.HttpResponse(response_data) if headers.get("Status"): response.status_code = int(headers["Status"].split()[0]) return response