diff options
Diffstat (limited to 'src/bin/ngit')
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 9 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/sync.rs | 10 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 11a812b..385eeca 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -9,6 +9,7 @@ use std::{ | |||
| 9 | 9 | ||
| 10 | use anyhow::{Context, Result, bail}; | 10 | use anyhow::{Context, Result, bail}; |
| 11 | use console::{Style, Term}; | 11 | use console::{Style, Term}; |
| 12 | use git2::Oid; | ||
| 12 | use ngit::{ | 13 | use ngit::{ |
| 13 | UrlWithoutSlash, | 14 | UrlWithoutSlash, |
| 14 | cli_interactor::{ | 15 | cli_interactor::{ |
| @@ -794,7 +795,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 794 | let mut required_oids = vec![]; | 795 | let mut required_oids = vec![]; |
| 795 | for tip in origin_state.values() { | 796 | for tip in origin_state.values() { |
| 796 | if let Ok(exist) = git_repo.does_commit_exist(tip) { | 797 | if let Ok(exist) = git_repo.does_commit_exist(tip) { |
| 797 | if !exist { | 798 | let oid_exists_as_tag = Oid::from_str(tip).is_ok_and(|tip| { |
| 799 | git_repo | ||
| 800 | .git_repo | ||
| 801 | .find_object(tip, Some(git2::ObjectType::Tag)) | ||
| 802 | .is_ok() | ||
| 803 | }); | ||
| 804 | if !exist && !oid_exists_as_tag { | ||
| 798 | required_oids.push(tip.clone()); | 805 | required_oids.push(tip.clone()); |
| 799 | } | 806 | } |
| 800 | } | 807 | } |
diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs index 1a2d4ee..0860cc4 100644 --- a/src/bin/ngit/sub_commands/sync.rs +++ b/src/bin/ngit/sub_commands/sync.rs | |||
| @@ -2,6 +2,7 @@ use std::collections::HashMap; | |||
| 2 | 2 | ||
| 3 | use anyhow::{Context, Result, bail}; | 3 | use anyhow::{Context, Result, bail}; |
| 4 | use console::Term; | 4 | use console::Term; |
| 5 | use git2::Oid; | ||
| 5 | use ngit::{ | 6 | use ngit::{ |
| 6 | client::{ | 7 | client::{ |
| 7 | Client, Connect, Params, fetching_with_report, get_repo_ref_from_cache, | 8 | Client, Connect, Params, fetching_with_report, get_repo_ref_from_cache, |
| @@ -239,7 +240,14 @@ fn identify_missing_refs(git_repo: &Repo, state: &HashMap<String, String>) -> Ve | |||
| 239 | let mut missing_oids = vec![]; | 240 | let mut missing_oids = vec![]; |
| 240 | for tip in state.values() { | 241 | for tip in state.values() { |
| 241 | if let Ok(exist) = git_repo.does_commit_exist(tip) { | 242 | if let Ok(exist) = git_repo.does_commit_exist(tip) { |
| 242 | if !exist { | 243 | let oid_exists_as_tag = Oid::from_str(tip).is_ok_and(|tip| { |
| 244 | git_repo | ||
| 245 | .git_repo | ||
| 246 | .find_object(tip, Some(git2::ObjectType::Tag)) | ||
| 247 | .is_ok() | ||
| 248 | }); | ||
| 249 | |||
| 250 | if !exist && !oid_exists_as_tag { | ||
| 243 | missing_oids.push(tip.to_string()); | 251 | missing_oids.push(tip.to_string()); |
| 244 | } | 252 | } |
| 245 | } | 253 | } |