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

Method resolve_author

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

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

Callers 1

runMethod · 0.80

Calls 8

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

Tested by

no test coverage detected