MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_author

Method resolve_author

atomic-cli/src/commands/record/builder.rs:70–113  ·  view source on GitHub ↗

Get the author from identity store or command-line override. Priority: 1. --identity flag (specific identity by name) 2. --author flag (manual override) 3. --usage flag (default identity for usage context) 4. Global default identity 5. Fallback to empty author (let repository handle it)

(&self)

Source from the content-addressed store, hash-verified

68 /// 4. Global default identity
69 /// 5. Fallback to empty author (let repository handle it)
70 pub(super) fn resolve_author(&self) -> CliResult<Option<Author>> {
71 // Try to open identity store
72 let store = IdentityStore::open_default().ok();
73
74 // 1. If --identity is specified, load that specific identity
75 if let Some(identity_name) = &self.identity {
76 let store = store.ok_or_else(|| {
77 CliError::Internal(anyhow::anyhow!(
78 "Identity store not available. Cannot use --identity flag."
79 ))
80 })?;
81
82 let identity = store
83 .load_by_name(identity_name)
84 .map_err(|_| CliError::IdentityNotFound(identity_name.clone()))?;
85
86 return Ok(Some(identity_to_author(&identity)));
87 }
88
89 // 2. If --author is specified, use the manual override
90 if let Some(author) = self.parse_author() {
91 return Ok(Some(author));
92 }
93
94 // 3. If --usage is specified, get default for that usage
95 if let Some(usage_str) = &self.usage {
96 if let Some(ref store) = store {
97 let usage = IdentityUsage::parse(usage_str);
98 if let Ok(Some(identity)) = store.get_default_for_usage(&usage) {
99 return Ok(Some(identity_to_author(&identity)));
100 }
101 }
102 }
103
104 // 4. Try to get global default identity
105 if let Some(ref store) = store {
106 if let Ok(Some(identity)) = store.get_default() {
107 return Ok(Some(identity_to_author(&identity)));
108 }
109 }
110
111 // 5. No identity available
112 Ok(None)
113 }
114
115 /// Get the commit message, potentially from editor.
116 pub(super) fn get_message(&self) -> CliResult<String> {

Callers 1

runMethod · 0.80

Calls 7

identity_to_authorFunction · 0.85
parseFunction · 0.85
load_by_nameMethod · 0.80
get_default_for_usageMethod · 0.80
cloneMethod · 0.45
parse_authorMethod · 0.45
get_defaultMethod · 0.45

Tested by

no test coverage detected