Show More
@@ -513,6 +513,8 b' class ScmModel(BaseModel):' | |||||
513 | :param commit_id: commit id for which to list nodes |
|
513 | :param commit_id: commit id for which to list nodes | |
514 | :param root_path: root path to list |
|
514 | :param root_path: root path to list | |
515 | :param flat: return as a list, if False returns a dict with description |
|
515 | :param flat: return as a list, if False returns a dict with description | |
|
516 | :param extended_info: show additional info such as md5, binary, size etc | |||
|
517 | :param content: add nodes content to the return data | |||
516 | :param max_file_bytes: will not return file contents over this limit |
|
518 | :param max_file_bytes: will not return file contents over this limit | |
517 |
|
519 | |||
518 | """ |
|
520 | """ | |
@@ -523,15 +525,14 b' class ScmModel(BaseModel):' | |||||
523 | commit = _repo.scm_instance().get_commit(commit_id=commit_id) |
|
525 | commit = _repo.scm_instance().get_commit(commit_id=commit_id) | |
524 | root_path = root_path.lstrip('/') |
|
526 | root_path = root_path.lstrip('/') | |
525 | for __, dirs, files in commit.walk(root_path): |
|
527 | for __, dirs, files in commit.walk(root_path): | |
|
528 | ||||
526 | for f in files: |
|
529 | for f in files: | |
527 | _content = None |
|
530 | _content = None | |
528 | _data = f.unicode_path |
|
531 | _data = f_name = f.unicode_path | |
529 | over_size_limit = (max_file_bytes is not None |
|
|||
530 | and f.size > max_file_bytes) |
|
|||
531 |
|
532 | |||
532 | if not flat: |
|
533 | if not flat: | |
533 | _data = { |
|
534 | _data = { | |
534 |
"name": h.escape(f |
|
535 | "name": h.escape(f_name), | |
535 | "type": "file", |
|
536 | "type": "file", | |
536 | } |
|
537 | } | |
537 | if extended_info: |
|
538 | if extended_info: | |
@@ -545,6 +546,8 b' class ScmModel(BaseModel):' | |||||
545 | }) |
|
546 | }) | |
546 |
|
547 | |||
547 | if content: |
|
548 | if content: | |
|
549 | over_size_limit = (max_file_bytes is not None | |||
|
550 | and f.size > max_file_bytes) | |||
548 | full_content = None |
|
551 | full_content = None | |
549 | if not f.is_binary and not over_size_limit: |
|
552 | if not f.is_binary and not over_size_limit: | |
550 | full_content = safe_str(f.content) |
|
553 | full_content = safe_str(f.content) | |
@@ -553,11 +556,12 b' class ScmModel(BaseModel):' | |||||
553 | "content": full_content, |
|
556 | "content": full_content, | |
554 | }) |
|
557 | }) | |
555 | _files.append(_data) |
|
558 | _files.append(_data) | |
|
559 | ||||
556 | for d in dirs: |
|
560 | for d in dirs: | |
557 | _data = d.unicode_path |
|
561 | _data = d_name = d.unicode_path | |
558 | if not flat: |
|
562 | if not flat: | |
559 | _data = { |
|
563 | _data = { | |
560 |
"name": h.escape(d |
|
564 | "name": h.escape(d_name), | |
561 | "type": "dir", |
|
565 | "type": "dir", | |
562 | } |
|
566 | } | |
563 | if extended_info: |
|
567 | if extended_info: |
General Comments 0
You need to be logged in to leave comments.
Login now