-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
Update git clone logic in build.xml #4891
Conversation
Grinder_jck test: 2010/2011 |
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.
Regarding the testing, I think we can reserve a machine to delete the git folder, then mkdir a normal folder with the same name (so git will fail), in this scenario, your code will be tested then.
a5c664d
to
de22015
Compare
Grinder_jck test: 2057 |
de22015
to
1c67fbc
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.
LGTM. Thanks @annaibm
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.
This problem is not limited to git clone. It is for general git cmd. I think it would be easier to rewrite the logic from scratch. ant script may not be the best way to do it.
4d99ca5
to
ad497ba
Compare
Converted the PR in draft. Please change the PR in |
1c35c3d
to
ed7215c
Compare
Grinder Test: 2103 |
jck/build.xml
Outdated
</if> | ||
</then> | ||
</if> | ||
<exec executable="bash" failonerror="false"> |
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.
Not sure if we need to set true
here?
0cbb3c4
to
61cb8cc
Compare
jck/update_git_material.sh
Outdated
fi | ||
} | ||
|
||
# Function to perform hard reset for z/OS |
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.
Why is this needed?
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.
Will need to remove this function as perform_hard_reset_and_pull
needs to handle both ZOS and non-ZOS.
61cb8cc
to
747d60f
Compare
jck/update_git_material.sh
Outdated
cd "$JCK_ROOT_USED" || { | ||
echo "Failed to change directory to $JCK_ROOT_USED" | ||
exit 1 | ||
} |
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.
Did you experience this case where the dir exist but you cannot cd into? The only case that I can think of is due to permission. The risk is very low. If it happens, this should be caught in line 140. I would prefer to remove L134 - L138.
The current PR only adds the error check in the places that we think it may fail. This is not sufficient. The better way to do this is to use
https://stackoverflow.com/questions/22009364/is-there-a-try-catch-command-in-bash Also, this can help us to write clean code to avoid repeatedly calling the same functions. For example, |
510defa
to
3aca90e
Compare
3aca90e
to
2ed66f1
Compare
# Catch block | ||
if [ "$global_error" -eq 1 ]; then | ||
handle_error | ||
fi |
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.
Did the following work?
{
check_and_handle_updates
} || {
git_clone
}
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 had tried the above method but it doesnt catch errors happening under functions within perform_hard_reset
or other places as such. So need to add error handling to check the error code returned in addition to trap statement.
7f8381c
to
d19fefc
Compare
|
||
# Try block | ||
if [ -d "$JCK_ROOT_USED" ] && { [ -d "$JCK_ROOT_USED/.git" ] || git -C "$JCK_ROOT_USED" rev-parse --is-inside-work-tree &>/dev/null; }; then | ||
echo "The directory is a valid Git repository." |
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.
We need to clean all unstaged change.
git -C $JCK_ROOT_USED clean -fd
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.
Yes we are handling it under check_and_handle_updates
method, does that suffice?
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.
no, it is not. In some cases, someone can manually change the file on disk without committing. Therefore, the SHA is the same. check_and_handle_updates does not catch this case.
- Removes prestaged jck material and reclones it, if git command fails resolves: adoptium#4846 Signed-off-by: Anna Babu Palathingal <[email protected]>
d19fefc
to
08081d5
Compare
Removes prestaged jck material and reclones it, if git command fails.
resolves: #4846