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

Method resolve_author

atomic-cli/src/commands/record/builder.rs:69–112  ·  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

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

Callers 1

runMethod · 0.80

Calls 6

identity_to_authorFunction · 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