upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/init.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-11-27 13:23:49 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-11-27 14:02:24 +0000
commit7e0b860eeb40d5b275a8a42aee8c78d85f73f713 (patch)
tree667ed02956077c7350acb4e3d1a321e8c2c4c6e5 /src/bin/ngit/sub_commands/init.rs
parent17640d83f01016142f9200138a591276bb80e157 (diff)
fix(init): improve git server explaination
and move it below maintainers input
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
-rw-r--r--src/bin/ngit/sub_commands/init.rs115
1 files changed, 70 insertions, 45 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index d0b4b6d..0f6a77c 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -164,50 +164,6 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
164 )?, 164 )?,
165 }; 165 };
166 166
167 let git_server = if args.clone_url.is_empty() {
168 Interactor::default()
169 .input(
170 PromptInputParms::default()
171 .with_prompt("clone url (for fetch)")
172 .with_default(if let Some(repo_ref) = &repo_ref {
173 repo_ref.git_server.clone().join(" ")
174 } else if let Ok(url) = git_repo.get_origin_url() {
175 if let Ok(fetch_url) = convert_clone_url_to_https(&url) {
176 fetch_url
177 } else {
178 // local repo or custom protocol
179 url
180 }
181 } else {
182 String::new()
183 }),
184 )?
185 .split(' ')
186 .map(std::string::ToString::to_string)
187 .collect()
188 } else {
189 args.clone_url.clone()
190 };
191
192 let web: Vec<String> = if args.web.is_empty() {
193 Interactor::default()
194 .input(
195 PromptInputParms::default()
196 .with_prompt("web")
197 .optional()
198 .with_default(if let Some(repo_ref) = &repo_ref {
199 repo_ref.web.clone().join(" ")
200 } else {
201 format!("https://gitworkshop.dev/repo/{}", &identifier)
202 }),
203 )?
204 .split(' ')
205 .map(std::string::ToString::to_string)
206 .collect()
207 } else {
208 args.web.clone()
209 };
210
211 let maintainers: Vec<PublicKey> = { 167 let maintainers: Vec<PublicKey> = {
212 let mut dont_ask = !args.other_maintainers.is_empty(); 168 let mut dont_ask = !args.other_maintainers.is_empty();
213 let mut maintainers_string = if !args.other_maintainers.is_empty() { 169 let mut maintainers_string = if !args.other_maintainers.is_empty() {
@@ -309,6 +265,72 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
309 } 265 }
310 }; 266 };
311 267
268 let no_state = if let Ok(Some(s)) = git_repo.get_git_config_item("nostr.nostate", None) {
269 s == "true"
270 } else {
271 false
272 };
273 if no_state {
274 println!(
275 "you have opted out of storing git state on nostr, so a git server must be used for the state of authoritative branches, tags and related git objects."
276 );
277 } else {
278 println!(
279 "your repository state will be stored on nostr, but a git server is still required to store the git objects associated with this state."
280 );
281 }
282 println!(
283 "you can change this git server at any time and even configure multiple servers for redundancy. In this case, the git plugin will push to all of them when using the nostr remote."
284 );
285 println!("only maintainers need write access as PRs are sent over nostr.");
286 println!(
287 "a lightweight git server implementation for use with nostr, requiring no signup, is in development. several providers have shown interest in hosting it. for now use github, codeberg, or self-hosted song, forge, etc."
288 );
289
290 let git_server = if args.clone_url.is_empty() {
291 Interactor::default()
292 .input(
293 PromptInputParms::default()
294 .with_prompt("git server remote url(s) (space seperated)")
295 .with_default(if let Some(repo_ref) = &repo_ref {
296 repo_ref.git_server.clone().join(" ")
297 } else if let Ok(url) = git_repo.get_origin_url() {
298 if let Ok(fetch_url) = convert_clone_url_to_https(&url) {
299 fetch_url
300 } else {
301 // local repo or custom protocol
302 url
303 }
304 } else {
305 String::new()
306 }),
307 )?
308 .split(' ')
309 .map(std::string::ToString::to_string)
310 .collect()
311 } else {
312 args.clone_url.clone()
313 };
314
315 let web: Vec<String> = if args.web.is_empty() {
316 Interactor::default()
317 .input(
318 PromptInputParms::default()
319 .with_prompt("repo website")
320 .optional()
321 .with_default(if let Some(repo_ref) = &repo_ref {
322 repo_ref.web.clone().join(" ")
323 } else {
324 format!("https://gitworkshop.dev/repo/{}", &identifier)
325 }),
326 )?
327 .split(' ')
328 .map(std::string::ToString::to_string)
329 .collect()
330 } else {
331 args.web.clone()
332 };
333
312 // TODO: check if relays are free to post to so contributors can submit patches 334 // TODO: check if relays are free to post to so contributors can submit patches
313 // TODO: recommend some reliable free ones 335 // TODO: recommend some reliable free ones
314 let relays: Vec<String> = if args.relays.is_empty() { 336 let relays: Vec<String> = if args.relays.is_empty() {
@@ -331,6 +353,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
331 args.relays.clone() 353 args.relays.clone()
332 }; 354 };
333 355
356 println!(
357 "the earliest unique commit helps with discoverability. It defaults to the root commit. Only change this if your repo has completely forked off an has formed its own identity."
358 );
334 let earliest_unique_commit = match &args.earliest_unique_commit { 359 let earliest_unique_commit = match &args.earliest_unique_commit {
335 Some(t) => t.clone(), 360 Some(t) => t.clone(),
336 None => { 361 None => {
@@ -342,7 +367,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
342 loop { 367 loop {
343 earliest_unique_commit = Interactor::default().input( 368 earliest_unique_commit = Interactor::default().input(
344 PromptInputParms::default() 369 PromptInputParms::default()
345 .with_prompt("earliest unique commit") 370 .with_prompt("earliest unique commit (to help with discoverability)")
346 .with_default(earliest_unique_commit.clone()), 371 .with_default(earliest_unique_commit.clone()),
347 )?; 372 )?;
348 if let Ok(exists) = git_repo.does_commit_exist(&earliest_unique_commit) { 373 if let Ok(exists) = git_repo.does_commit_exist(&earliest_unique_commit) {