-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Project Submodule Support #729
Comments
I did some investigating and I think this may be harder to implement than I had initially hoped. I am having trouble coming up with a git command which simply lists the changed files in the base project as well as submodules. Running There's 2 solutions I've come up with that I think would work:
I think the best approach is solution 1. I don't think this is an ideal solution, but I think this would be the easiest and most reliable way to add this functionality. |
Hi @Russman12 ! Thanks for raising this feature request and thanks for contributing in making this project better! Thank you very much for all the interesting spiking you've done so far, very helpful. Indeed this PR allow sgd to work on submodules. For the solution 1/, we are using For the solution 2/ it would work but it is indeed a complex solution to build and maintain. We are currently under a refactoring around how we interact with git. I'll try to add this feature inside the refactoring. Stay tuned ! |
Hi @Russman12 I'm giving you an update as I'm currently spiking on this feature. So far, I think it would be doable to include submodules in the git refactoring in order to get the list of changes. What I'm not sure yet is for the Plus, it seems all this thinking would not work with I'm considering another approach in parallel: documenting a way to script multiple calls to SGD, one for the main repository and one for each submodules of the main repository and find a way to reconciliate it in the output. |
Hey @scolladon, Thanks for the update. I had not considered documenting a script with merging functionality. I think it could work, though the script could get complicated. Additionally, if the script is written in bash, then it might not be very portable. For example, I run git bash on windows, and I can't run jq commands. I'm not sure if a similar limitation exists for a bash script that modifies xml. |
Hi @Russman12 ! I found it pretty hard to know how to compare from a submodule because the program needs to have the sha the submodule were pointing to at the I come up with this little bash script to handle submodules (not well tested): #!/bin/bash
# store the output folder path (or default it to output)
output="${1:-output}"
# store the repo path
repo="${2:-.}"
from="${3:-HEAD~1}"
to="${4:-HEAD}"
current_sha=`git rev-parse HEAD`
pushd $repo
submodules_list=`git config --file .gitmodules --get-regexp path | awk '{ print $2 }'`
submodules=(${submodules_list// / })
main () {
# current repo use case
generate_delta_and_merge "." "$from" "$to"
git submodule status | while read submodules_list
do
handle_submodule $submodules_list
done
cleanup
}
generate_delta_and_merge () {
local repo=$1
local from=$2
local to="${3:-HEAD}"
sfdx sgd:source:delta -d -f $from -t $to -o $output -r $repo
merge-manifest "package"
merge-manifest "destructiveChanges"
}
handle_submodule () {
local su_to=$1
local su_path=$2
git checkout -f $from
pushd $su_path
local su_from=`git rev-parse HEAD`
popd
git checkout -f $current_sha
# submodules use case
if [ "$su_from" != "$su_to" ]; then
generate_delta_and_merge "." "$su_from" "$su_to"
fi
}
cleanup () {
rm -rf $output/package/merged-*.xml
rm -rf $output/destructiveChanges/merged-*.xml
}
merge-manifest () {
smp -p $output/$1/** -o "$output/$1/merged-$1.xml"
}
main
popd It uses smp, a small a fast package.xml merge tool I think it would be easy to make it works for subtree as well Does it helps you ? |
Hello @scolladon, Thanks for the script! I will test this as soon as I can and report back. Thanks, |
Hey @scolladon, Sorry it has taken so long for me to get back with this. I have not been able to test the bash script yet, but the concept seems pretty simple. I will close this issue. Thanks, |
Is your proposal related to a problem?
no
SGD executions don't include changes to submodules.
Describe a solution you propose
When a submodule is updated, the process should include diffs from submodules within the project. The following git command achieves this:
git diff sha1 sha2 --submodule=diff
There could also be a new flag to go with this functionality. something like
--include-submodules
. This would preserve the existing functionality and allow users to opt in. However, I'm not sure if there's actually a need to not diff submodules.Describe alternatives you've considered
I've tried setting my git config to automatically diff submodules. I confirmed that it was working when running git diff, but that did not affect the SGD commands and I was unable to produce a manifest with the changed submodule files. Another potential solution would be to make the diff command respect the git config. If the project is using git to determine the diffs, I'm not exactly sure why the git config wouldn't be respected.
Additional context
This pull request seems to relate to submodules. After reading it I thought that this functionality was already supported. Perhaps I am doing something wrong?
The text was updated successfully, but these errors were encountered: