-
Notifications
You must be signed in to change notification settings - Fork 9
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
Script for Header Migration #712
Conversation
are you planning to match the pattern of commits used in gazebosim/gz-utils#51? I think it's helpful to be strategic about the commits because the overall diff is very hard to read |
The script is currently in a state where it reproduces all the changes made by gazebosim/gz-utils#51 except making the I'll be implementing that (though the Then I'll also work on replacing the relevant statements in N.B.: I'll split the commits accordingly when it's ready to start implementing git commit functionality to follow the pattern in the pull request. |
I just noticed the following header file with |
I'll write functionality to migrate the file with redirection, but not the class name. Let's do class and variable name migration in a separate set of PRs so things are cleaner? |
9f44062
to
9e00c44
Compare
f34aa93
to
ce51fda
Compare
there's a lot happening so it's a bit hard to follow this script. I would imagine the first commit could be done with code like the following:
|
fc72382
to
0ab424b
Compare
I was using That is no longer the case, and history should be preserved! 🎉 |
8457740
to
9c353f2
Compare
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.
Seems like the script is in active development. If that is the case please mark it as Draft.
Before looking at the code, the script is placed under jenkins-scripts/tools
but I believe that it does not have anything to do with Jenkins. We can create a new subdir in the root of the repo named something like code-repo-scripts
to host the scripts designed to work with repository code. My intention is to move source_changelog
into it but that will require a different PR.
@@ -0,0 +1,500 @@ | |||
#!/usr/bin/env bash | |||
# Copyright (C) 2022 Open Source Robotics Foundation |
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.
Maybe adding a set -e
to stop on errors at the begging can help to detect hidden problems.
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.
Good call! cc67a0b
b688e3a
to
4ba4043
Compare
4ba4043
to
522cc9c
Compare
I agree! I couldn't really find another place to put this into... |
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
522cc9c
to
cc67a0b
Compare
Signed-off-by: methylDragon <[email protected]>
I just saw this comment. On #677 I created the |
Signed-off-by: methylDragon <[email protected]>
Signed-off-by: methylDragon <[email protected]>
In the end it was still better to manually copy and move from the install space (too many edge cases), and it's unlikely we'll need to keep using this functionality, so I'm closing this :( |
Description
This is related to #711
And is an extended scripted version of gazebosim/gz-utils#51
It should:
gz/*
and add redirect headers toignition/*
#include <ignition/*>
statements in header files with#include <gz/*>
Export.hh
and<lib>.hh
header files#include <ignition/*>
statements in src, test, and examples source code with#include <gz/*>
Examples
With the script placed into the root of
ign-utils
, on the main branch and an emptyheader_migration
branch, run./header_migration_script.sh
PR generated from this script: gazebosim/gz-utils#53
Further Work
Caveats
Generated Files
This script can't handle generated files because it has no knowledge of them, and to get that functionality, it'll need to be able to intelligently go up and down the directory tree, looking into CMake files and the like.
There is too much variance between the packages to do this quickly (and robustly), so for those cases, users will have to manually do the migration. These are some of the common edge cases:
Export.hh
and<lib>.<lib.hh
files have to be manually added since they're usually dynamically generated byign-cmake
CMakeLists.txt
files (that usually have to be added)Typically, the way you'd surface these issues is, once you've done the migration with the script, install the unmigrated version alongside the migrated version (across two workspaces), then use meld to run a directory diff on:
migrated_ws/install/ignition-<lib>/include/ignition/<lib>
vs;unmigrated_ws/install/ignition-<lib>/include/ignition/<lib>
migrated_ws/install/ignition-<lib>/include/ignition/<lib>/gz
vs;unmigrated_ws/install/ignition-<lib>/include/ignition/<lib>/ignition
Greedy Matching
There are a couple of instances where the script will match greedily and change something that shouldn't be changed. This is because I am erring on the side of editing something (so it is visible to a user) rather than missing something.
I think the script gets it right in the ballpark of 90% correct, but there are about 10% of cases that are false positive matches that require users to manually discard changes for.
To aid in this, the script has multiple stopping and review points for a user to open the git diffs on a program like GitKraken to double-check any changes made.
Already Migrated Files
(This is sort of a variant of greedy matching)
Be aware that the script will greedily convert already migrated
gz
headers into redirection headers! Please check to make sure it doesn't do that!Unrelated To This PR