Skip to content

Commit

Permalink
Unglue glued-up words in multiline strings
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed May 11, 2022
1 parent e6d9c59 commit edd8ce7
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 51 deletions.
8 changes: 4 additions & 4 deletions ci/checks/prohibit-strings-split-without-delimiter.awk
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ BEGIN { exit_code = 0 }
FNR == 1 { prev_is_unsafe_terminated_string = 0 }

prev_is_unsafe_terminated_string && /^ *f?["'][^ ]/ {
print FILENAME ":" FNR-1 "-" FNR ": it looks that the string is split without a delimeter, words will be glued up together when printed"
print FILENAME ":" FNR-1 "-" FNR ": it looks that the string is split without a delimiter, words will be glued up together when printed"
print ""
print prev
print $0
print "\n"
exit_code = 1
}

{ prev_is_unsafe_terminated_string = 0 }
{ prev_is_unsafe_terminated_string = 0 }

/[^ ]["'] \\$/ { prev_is_unsafe_terminated_string = 1 }
/[^ ]["'] *\\?$/ { prev_is_unsafe_terminated_string = 1 }

/\\n" \\$/ { prev_is_unsafe_terminated_string = 0 }
/\\n["'] *\\?$/ { prev_is_unsafe_terminated_string = 0 }

{ prev = $0 }

Expand Down
13 changes: 7 additions & 6 deletions git_machete/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def up_branch(self, val: Dict[LocalBranchShortName, Optional[LocalBranchShortNam
def expect_in_managed_branches(self, branch: LocalBranchShortName) -> None:
if branch not in self.managed_branches:
raise MacheteException(
f"Branch `{branch}` not found in the tree of branch dependencies."
f"\nUse `git machete add {branch}` or `git machete edit`")
f"Branch `{branch}` not found in the tree of branch dependencies.\n"
f"Use `git machete add {branch}` or `git machete edit`")

def expect_at_least_one_managed_branch(self) -> None:
if not self.__roots:
Expand Down Expand Up @@ -1623,13 +1623,14 @@ def set_fork_point_override(self, branch: LocalBranchShortName, to_revision: Any
branch_hash = self.__git.get_commit_hash_by_revision(branch)
self.__git.set_config_attr(while_descendant_of_key, branch_hash)

print(fmt(f"Fork point for <b>{branch}</b> is overridden to <b>"
f"{self.__git.get_revision_repr(to_revision)}</b>.\n",
print(fmt(f"Fork point for <b>{branch}</b> is overridden to "
f"<b>{self.__git.get_revision_repr(to_revision)}</b>.\n",
f"This applies as long as {branch} points to (or is descendant of)"
" its current head (commit "
f"{self.__git.get_short_commit_hash_by_revision(branch_hash)}).\n\n",
f"This information is stored under git config keys:\n * `{to_key}"
f"`\n * `{while_descendant_of_key}`\n\n",
f"This information is stored under git config keys:\n"
f" * `{to_key}`\n"
f" * `{while_descendant_of_key}`\n\n",
"To unset this override, use:\n `git machete fork-point "
f"--unset-override {branch}`"))

Expand Down
2 changes: 1 addition & 1 deletion git_machete/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def __fire_github_api_request(method: str, path: str, token: Optional[str], requ
else:
raise MacheteException(
first_line + f'You might not have the required permissions for this repository. '
f'Provide a GitHub API token with `repo` access via one of the: {get_github_token_possible_providers()}'
f'Provide a GitHub API token with `repo` access via one of the: {get_github_token_possible_providers()} '
'Visit `https://github.com/settings/tokens` to generate a new one.')
elif err.code == http.HTTPStatus.NOT_FOUND:
raise MacheteException(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def test_advance_with_one_downstream_branch(self, mocker: Any) -> None:

assert level_1_commit_hash == \
root_top_commit_hash, \
("Verify that when there is only one, rebased downstream branch of a"
"current branch 'git machete advance' merges commits from that branch"
("Verify that when there is only one, rebased downstream branch of a "
"current branch 'git machete advance' merges commits from that branch "
"and slides out child branches of the downstream branch."
)
assert "level-1-branch" not in \
Expand Down
38 changes: 19 additions & 19 deletions tests/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_go_first_root_with_downstream(self, mocker: Any) -> None:

assert 'level-1a-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go first' performs 'git checkout' to"
("Verify that 'git machete go first' performs 'git checkout' to "
"the first downstream branch of a root branch if root branch "
"has any downstream branches."
)
Expand Down Expand Up @@ -154,15 +154,15 @@ def test_go_first_root_without_downstream(self, mocker: Any) -> None:

assert 'level-0-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go first' set current branch to root"
("Verify that 'git machete go first' set current branch to root "
"if root branch has no downstream."
)
# check short command behaviour
launch_command("g", "f")

assert 'level-0-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete g f' set current branch to root"
("Verify that 'git machete g f' set current branch to root "
"if root branch has no downstream."
)

Expand Down Expand Up @@ -198,7 +198,7 @@ def test_go_last(self, mocker: Any) -> None:

assert 'level-1b-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go last' performs 'git checkout' to"
("Verify that 'git machete go last' performs 'git checkout' to "
"the last downstream branch of a root branch if root branch "
"has any downstream branches."
)
Expand All @@ -208,7 +208,7 @@ def test_go_last(self, mocker: Any) -> None:

assert 'level-1b-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete g l' performs 'git checkout' to"
("Verify that 'git machete g l' performs 'git checkout' to "
"the last downstream branch of a root branch if root branch "
"has any downstream branches."
)
Expand Down Expand Up @@ -240,8 +240,8 @@ def test_go_next_successor_exists(self, mocker: Any) -> None:

assert 'level-1b-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go next' performs 'git checkout' to"
"the next downstream branch right after the current one in the"
("Verify that 'git machete go next' performs 'git checkout' to "
"the next downstream branch right after the current one in the "
"config file if successor branch exists."
)
# check short command behaviour
Expand All @@ -250,8 +250,8 @@ def test_go_next_successor_exists(self, mocker: Any) -> None:

assert 'level-1b-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete g n' performs 'git checkout' to"
"the next downstream branch right after the current one in the"
("Verify that 'git machete g n' performs 'git checkout' to "
"the next downstream branch right after the current one in the "
"config file if successor branch exists."
)

Expand Down Expand Up @@ -279,7 +279,7 @@ def test_go_next_successor_on_another_root_tree(self, mocker: Any) -> None:

assert 'x-additional-root' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go next' can checkout to branch that doesn't"
("Verify that 'git machete go next' can checkout to branch that doesn't "
"share root with the current branch."
)
# check short command behaviour
Expand All @@ -288,7 +288,7 @@ def test_go_next_successor_on_another_root_tree(self, mocker: Any) -> None:

assert 'x-additional-root' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete g n' can checkout to branch that doesn't"
("Verify that 'git machete g n' can checkout to branch that doesn't "
"share root with the current branch."
)

Expand Down Expand Up @@ -318,8 +318,8 @@ def test_go_prev_successor_exists(self, mocker: Any) -> None:

assert 'level-2a-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go prev' performs 'git checkout' to"
"the branch right before the current one in the config file"
("Verify that 'git machete go prev' performs 'git checkout' to "
"the branch right before the current one in the config file "
"when predecessor branch exists within the root tree."
)
# check short command behaviour
Expand All @@ -328,8 +328,8 @@ def test_go_prev_successor_exists(self, mocker: Any) -> None:

assert 'level-2a-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete g p' performs 'git checkout' to"
"the branch right before the current one in the config file"
("Verify that 'git machete g p' performs 'git checkout' to "
"the branch right before the current one in the config file "
"when predecessor branch exists within the root tree."
)

Expand All @@ -355,7 +355,7 @@ def test_go_prev_successor_on_another_root_tree(self, mocker: Any) -> None:

assert 'a-additional-root' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go prev' can checkout to branch that doesn't"
("Verify that 'git machete go prev' can checkout to branch that doesn't "
"share root with the current branch."
)
# check short command behaviour
Expand All @@ -364,7 +364,7 @@ def test_go_prev_successor_on_another_root_tree(self, mocker: Any) -> None:

assert 'a-additional-root' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete g p' can checkout to branch that doesn't"
("Verify that 'git machete g p' can checkout to branch that doesn't "
"share root with the current branch."
)

Expand Down Expand Up @@ -398,7 +398,7 @@ def test_go_root(self, mocker: Any) -> None:

assert 'level-0-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete go root' performs 'git checkout' to"
("Verify that 'git machete go root' performs 'git checkout' to "
"the root of the current branch."
)
# check short command behaviour
Expand All @@ -407,6 +407,6 @@ def test_go_root(self, mocker: Any) -> None:

assert 'level-0-branch' == \
launch_command("show", "current").strip(), \
("Verify that 'git machete g r' performs 'git checkout' to"
("Verify that 'git machete g r' performs 'git checkout' to "
"the root of the current branch."
)
36 changes: 18 additions & 18 deletions tests/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ def test_show_up(self, mocker: Any) -> None:

assert 'level-0-branch' == \
launch_command("show", "up").strip(), \
("Verify that 'git machete show up' displays name of a parent/upstream"
("Verify that 'git machete show up' displays name of a parent/upstream "
"branch one above current one."
) # check short command behaviour
assert 'level-0-branch' == \
launch_command("show", "u").strip(), \
("Verify that 'git machete show u' displays name of a parent/upstream"
("Verify that 'git machete show u' displays name of a parent/upstream "
"branch one above current one."
)

Expand Down Expand Up @@ -185,14 +185,14 @@ def test_show_first(self, mocker: Any) -> None:

assert 'level-1a-branch' == \
launch_command("show", "first").strip(), \
("Verify that 'git machete show first' displays name of the first downstream"
"branch of a root branch of the current branch in the config file if root"
("Verify that 'git machete show first' displays name of the first downstream "
"branch of a root branch of the current branch in the config file if root "
"branch has any downstream branches."
)
assert 'level-1a-branch' == \
launch_command("show", "f").strip(), \
("Verify that 'git machete show f' displays name of the first downstream"
"branch of a root branch of the current branch in the config file if root"
("Verify that 'git machete show f' displays name of the first downstream "
"branch of a root branch of the current branch in the config file if root "
"branch has any downstream branches."
)

Expand Down Expand Up @@ -227,14 +227,14 @@ def test_show_last(self, mocker: Any) -> None:

assert 'level-1b-branch' == \
launch_command("show", "last").strip(), \
("Verify that 'git machete show last' displays name of the last downstream"
"branch of a root branch of the current branch in the config file if root"
("Verify that 'git machete show last' displays name of the last downstream "
"branch of a root branch of the current branch in the config file if root "
"branch has any downstream branches."
)
assert 'level-1b-branch' == \
launch_command("show", "l").strip(), \
("Verify that 'git machete show l' displays name of the last downstream"
"branch of a root branch of the current branch in the config file if root"
("Verify that 'git machete show l' displays name of the last downstream "
"branch of a root branch of the current branch in the config file if root "
"branch has any downstream branches."
)

Expand Down Expand Up @@ -265,13 +265,13 @@ def test_show_next(self, mocker: Any) -> None:
assert 'level-1b-branch' == \
launch_command("show", "next").strip(), \
("Verify that 'git machete show next' displays name of "
"a branch right after the current one in the config file"
"a branch right after the current one in the config file "
"when successor branch exists within the root tree."
)
assert 'level-1b-branch' == \
launch_command("show", "n").strip(), \
("Verify that 'git machete show n' displays name of "
"a branch right after the current one in the config file"
"a branch right after the current one in the config file "
"when successor branch exists within the root tree."
)

Expand Down Expand Up @@ -300,14 +300,14 @@ def test_show_prev(self, mocker: Any) -> None:

assert 'level-2a-branch' == \
launch_command("show", "prev").strip(), \
("Verify that 'git machete show prev' displays name of"
"a branch right before the current one in the config file"
("Verify that 'git machete show prev' displays name of "
"a branch right before the current one in the config file "
"when predecessor branch exists within the root tree."
)
assert 'level-2a-branch' == \
launch_command("show", "p").strip(), \
("Verify that 'git machete show p' displays name of"
"a branch right before the current one in the config file"
("Verify that 'git machete show p' displays name of "
"a branch right before the current one in the config file "
"when predecessor branch exists within the root tree."
)

Expand Down Expand Up @@ -340,11 +340,11 @@ def test_show_root(self, mocker: Any) -> None:

assert 'level-0-branch' == \
launch_command("show", "root").strip(), \
("Verify that 'git machete show root' displays name of the root of"
("Verify that 'git machete show root' displays name of the root of "
"the current branch."
)
assert 'level-0-branch' == \
launch_command("show", "r").strip(), \
("Verify that 'git machete show r' displays name of the root of"
("Verify that 'git machete show r' displays name of the root of "
"the current branch."
)
2 changes: 1 addition & 1 deletion tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_update_with_fork_point_not_specified(self, mocker: Any) -> None:

assert parents_new_commit_hash == \
new_fork_point_hash, \
("Verify that 'git machete update --no-interactive-rebase' perform"
("Verify that 'git machete update --no-interactive-rebase' perform "
"'git rebase' to the parent branch of the current branch."
)

Expand Down

0 comments on commit edd8ce7

Please sign in to comment.