-
Notifications
You must be signed in to change notification settings - Fork 1
feat(submodule): disable command updates .gitmodules active status #50
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
Changes from 1 commit
219efea
f1e51cd
2556667
1558b51
0cc28f2
ef8f011
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1502,6 +1502,17 @@ impl GitManager { | |||||||||||||||||||||||||||||||||||||||||
| .submodules | ||||||||||||||||||||||||||||||||||||||||||
| .update_entry(name.to_string(), updated); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // Update .gitmodules | ||||||||||||||||||||||||||||||||||||||||||
| if let Ok(mut entries) = self.git_ops.read_gitmodules() { | ||||||||||||||||||||||||||||||||||||||||||
| if let Some(mut gitmodules_entry) = entries.get_submodule(name).cloned() { | ||||||||||||||||||||||||||||||||||||||||||
| gitmodules_entry.active = Some(false); | ||||||||||||||||||||||||||||||||||||||||||
| entries.update_entry(name.to_string(), gitmodules_entry); | ||||||||||||||||||||||||||||||||||||||||||
| if let Err(e) = self.git_ops.write_gitmodules(&entries) { | ||||||||||||||||||||||||||||||||||||||||||
| eprintln!("Warning: Failed to update .gitmodules: {e}"); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
| if let Some(mut gitmodules_entry) = entries.get_submodule(name).cloned() { | |
| gitmodules_entry.active = Some(false); | |
| entries.update_entry(name.to_string(), gitmodules_entry); | |
| if let Err(e) = self.git_ops.write_gitmodules(&entries) { | |
| eprintln!("Warning: Failed to update .gitmodules: {e}"); | |
| let gitmodules_key = if entries.get_submodule(name).is_some() { | |
| Some(name.to_string()) | |
| } else if entries.get_submodule(&path).is_some() { | |
| Some(path.clone()) | |
| } else { | |
| None | |
| }; | |
| if let Some(gitmodules_key) = gitmodules_key { | |
| if let Some(mut gitmodules_entry) = entries.get_submodule(&gitmodules_key).cloned() { | |
| gitmodules_entry.active = Some(false); | |
| entries.update_entry(gitmodules_key, gitmodules_entry); | |
| if let Err(e) = self.git_ops.write_gitmodules(&entries) { | |
| eprintln!("Warning: Failed to update .gitmodules: {e}"); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,6 +246,10 @@ impl GitOperations for Git2Operations { | |
| }; | ||
| config.set_str(&format!("submodule.{name}.update"), update_str)?; | ||
| } | ||
| if let Some(active) = entry.active { | ||
| let active_str = if active { "true" } else { "false" }; | ||
| config.set_str(&format!("submodule.{name}.active"), active_str)?; | ||
| } | ||
|
Comment on lines
+249
to
+252
|
||
| // Set URL if different | ||
| if let Some(url) = &entry.url | ||
| && submodule.url() != Some(url.as_str()) { | ||
|
|
||
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
.gitmodulesupdate looks up the entry byname, but.gitmodulessections are not guaranteed to use the same identifier as your config key (e.g., name vs path). Ifentry.pathdiffers fromname, this won’t update the intended.gitmodulessection. Consider locating the.gitmodulesentry by matchingentry.path(similar to other path-based lookups in the codebase) and then updating that section’sactiveflag.