Skip to content

Commit

Permalink
fix(cli): limit commit message length when there is too many files (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Mar 27, 2023
1 parent 3ad4ac3 commit 70cf36a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions renku/command/save.py
@@ -1,6 +1,5 @@
#
# Copyright 2017-2023 - Swiss Data Science Center (SDSC)
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
# Copyright Swiss Data Science Center (SDSC). A partnership between
# École Polytechnique Fédérale de Lausanne (EPFL) and
# Eidgenössische Technische Hochschule Zürich (ETHZ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
8 changes: 6 additions & 2 deletions renku/core/util/git.py
Expand Up @@ -490,7 +490,8 @@ def commit_changes(*paths: Union[Path, str], repository: "Repository", message=N
if saved_paths:
if not message:
# Show saved files in message
max_len = 100
max_line_len = 100
max_total_len = 100000
message = "Saved changes to: "
paths_with_lens = cast(
List[Tuple[str, int]],
Expand All @@ -501,7 +502,10 @@ def commit_changes(*paths: Union[Path, str], repository: "Repository", message=N
)[1:],
)
# limit first line to max_len characters
message += " ".join(p if l < max_len else "\n\t" + p for p, l in paths_with_lens)
message += " ".join(p if l < max_line_len else "\n\t" + p for p, l in paths_with_lens)

if len(message) > max_total_len:
message = message[: max_total_len - 3] + "..."

repository.commit(message)
except errors.GitCommandError as e:
Expand Down
5 changes: 2 additions & 3 deletions renku/infrastructure/repository.py
@@ -1,6 +1,5 @@
#
# Copyright 2018-2023- Swiss Data Science Center (SDSC)
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
# Copyright Swiss Data Science Center (SDSC). A partnership between
# École Polytechnique Fédérale de Lausanne (EPFL) and
# Eidgenössische Technische Hochschule Zürich (ETHZ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit 70cf36a

Please sign in to comment.