Trying to update submodules of a project with a script.

5 ビュー (過去 30 日間)
Claudio Rosso
Claudio Rosso 2024 年 7 月 30 日
コメント済み: Claudio Rosso 2024 年 7 月 31 日
Hello,
I'm trying to create a script to facilitate team member when they have to update submodules inside a project to a specific tag.
I have no problem for the upadate, but io'm quite stuck to the commit phase.
I try this list of commands:
commit_message = char(strcat("Moved submodule Standard to ", standard_tag, {newline}, "Moved submodule Common to ", common_tag));
git_command = ['git commit -m ' commit_message];
system(git_command);
but, when i try to execute the script, i have this errors:
error: pathspec 'submodule' did not match any file(s) known to git
error: pathspec 'Standard' did not match any file(s) known to git
error: pathspec 'to' did not match any file(s) known to git
error: pathspec '2024R2' did not match any file(s) known to git
I suppose that my issue is related to this:
git_command = 'git commit -m Moved submodule Standard to 2024R2
Moved submodule Common to 2024R2'
It seems that the system function can't isolate correctly the "message" for the commit. How can i solve this one.
Thank you in advance.
Best regards.
Claudio

採用された回答

Steven Lord
Steven Lord 2024 年 7 月 30 日
Try wrapping the message in quotes in the command to be executed.
commit_message = 'Moved submodule Standard to 2024R2';
Compare:
git_command1 = ['git commit -m ' commit_message]
git_command1 = 'git commit -m Moved submodule Standard to 2024R2'
and
git_command2 = ['git commit -m "' commit_message '"']
git_command2 = 'git commit -m "Moved submodule Standard to 2024R2"'
or
git_command3 = sprintf('git commit -m "%s"', commit_message)
git_command3 = 'git commit -m "Moved submodule Standard to 2024R2"'
Suppose in git_command1 one of the words in commit_message started with a - and was a valid option for "git commit"? Without the quotes, git commit should treat that as the option which may not be what you want.
Alternately, consider using the functionality provided in MATLAB itself for using Git rather than calling system to interact with git commands manually. See for example the documentation for the commit function for repo objects.
  1 件のコメント
Claudio Rosso
Claudio Rosso 2024 年 7 月 31 日
The second command seems work correctly, thank you for your fast answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSource Control についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by