-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add b4 Tool #3506
Open
adityagesh
wants to merge
3
commits into
main
Choose a base branch
from
aditya/tools_b4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−9
Open
Add b4 Tool #3506
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pathlib | ||
import re | ||
from typing import List, Type | ||
|
||
from lisa.executable import Tool | ||
from lisa.operating_system import Debian | ||
from lisa.tools.git import Git | ||
from lisa.tools.python import Pip | ||
from lisa.util import LisaException, find_group_in_lines | ||
|
||
|
||
class B4(Tool): | ||
# Output log is of the form | ||
# git am /mnt/code/linux/v2_20241029_xxx_offers.mbx | ||
_output_file_pattern = re.compile( | ||
r"^.*git.*/(?P<filename>[\w-]+\.mbx).*$", re.MULTILINE | ||
) | ||
|
||
@property | ||
def command(self) -> str: | ||
return "b4" | ||
|
||
@property | ||
def dependencies(self) -> List[Type[Tool]]: | ||
return [Git] | ||
|
||
@property | ||
def can_install(self) -> bool: | ||
return True | ||
|
||
def _install(self) -> bool: | ||
if isinstance(self.node.os, Debian): | ||
self.node.os.install_packages("b4") | ||
installed = self._check_exists() | ||
if not installed: | ||
pip = self.node.tools[Pip] | ||
pip.install_packages("b4", install_to_user=True) | ||
return self._check_exists() | ||
|
||
def am( | ||
self, message_id: str, output_dir: pathlib.PurePath, sudo: bool = False | ||
) -> pathlib.PurePath: | ||
result = self.run( | ||
f"am -o '{output_dir}' '{message_id}'", | ||
force_run=True, | ||
expected_exit_code=0, | ||
sudo=sudo, | ||
) | ||
filename = find_group_in_lines( | ||
lines=result.stdout, pattern=self._output_file_pattern, single_line=False | ||
).get("filename") | ||
if not filename: | ||
raise LisaException("Failed to get filename from b4 am output") | ||
return pathlib.PurePath(output_dir, filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just understood the scenario. Because the
.mbx
is always generated by b4, and the call sequence is always b4.am and git.apply. So the b4 can be called in git, or call git in b4, so it's easier to use.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apply_patch
andapply
are confusing in the Git tool.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool b4 has dependency on Git while pulling patches (taking Message_id as the parameter), so I don't think we can add b4 to Git.
Currently in Git.apply, it takes the path as parameter, which is basically the operation after we download the patch using b4.
B4 after downloading the patch should always call git apply to apply the patch.
The b4 apply that I showed above is : download patch using b4 -> apply downloaded patch using git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you recommending adding something like below in Git?
If we have the tool B4, it is possible someone uses it directly before invoking git. b4 will fail is git is not installed and not set as a dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's like below. There is no conflict to block direct use b4.