Skip to content

DRAFT: Port Tools/gittools/git-subsystems-split to Python #29733

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Apr 9, 2025

As discussed at:

Let's try to port Tools/gittools/git-subsystems-split to Python. This contains several building blocks but does not yet:

  • Enable the commit message editing functionality --> edit_subsystems_split_message()
  • get_subsystems() does not properly yield all subsystems (e.g., autotest, etc.)
  • Enable the creation of the multiple commits.

Basicly

if $option_edit; then
if [[ -z $EDITOR ]]; then
echo "Environment variable EDITOR is required for option --edit." >&2
exit 1
fi
($EDITOR "$MSG_FILE")
elif ! $option_copy; then
if head -n 1 "$MSG_FILE" | grep "^[^: ]\+\s*:" -q; then
sed '1 s,^[^: ]\+\s*,$subsystem,' -i "$MSG_FILE"
else
buff_file="$(mktemp)"
awk '
NR == 1 {
l=sub(/^\s\+/, "", $line);
print "$subsystem: " \
tolower(substr($l, 1, 1)) \
substr($l, 2);
}
NR != 1
' "$MSG_FILE" > "$buff_file"
mv "$buff_file" "$MSG_FILE"
rm "$buff_file"
fi
fi

@cclauss cclauss marked this pull request as draft April 9, 2025 10:02
@cclauss cclauss force-pushed the git-subsystems-split.py branch from 87f51fb to b403136 Compare April 9, 2025 11:25
@peterbarker
Copy link
Contributor

I like the concept, and mentioned a rewrite into Python was a good idea to @Hwurzburg yesterday. We need to be a bit more nuanced with some of the commits now-adays (eg. the prefix for a change made to board definitions under libraries/AP_HAL_ChibiOS/hwdef/ should be prefixd with hwdef not AP_HAL_ChibiOS. Translating to Python would be a prerequisite for that sort of change IMO.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 10, 2025

I see elsewhere that gawk is used instead of awk. Would that be a quick fix to my macOS issue?

Are the desired subsystem prefixes documented somewhere? What would the prefix be for files at the root (like #29734)? If someone can document desired subsystem prefixes that would move this forward.

All the logging can be stripped away but helps while this is still a draft.

I will work offline on the creation of multiple commits.

If anyone sees a more direct way to achieve this objective then I would be ok with closing this pr.

@tridge
Copy link
Contributor

tridge commented Apr 10, 2025

@cclauss I'm delighted to see this work! I was thinking of doing this myself, but happy for you to do it.
just put an easy to edit dictionary in the script for the mappings for special directories
for files at root, the only one regulary edited is wscript, which I normally prefix as "waf: xxxx"

@peterbarker
Copy link
Contributor

.... edits to Tools/ardupilotwaf/** also usually get labelled with waf:.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 12, 2025

@tridge wrote:

just put an easy to edit dictionary in the script for the mappings for special directories

Please read thru the get_commit_prefix_from_filepath() logic. I harvested several of your open PRs to get a hint about prefix logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants