new recipe default branch main instead of master #451

Merged
decentral1se merged 4 commits from defaultBranch into main 2024-12-21 18:11:13 +00:00
Member

Just saving my future self the trouble of searching "how to rename git branch" every-time I create a new recipe

Just saving my future self the trouble of searching "how to rename git branch" every-time I create a new recipe
ammaratef45 added 1 commit 2024-12-13 03:09:52 +00:00
new recipe default branch main instead of master
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
9510c04aeb
decentral1se reviewed 2024-12-14 21:19:04 +00:00
decentral1se left a comment
Owner

tysm for dipping into this, definitely important work!

tysm for dipping into this, definitely important work!
pkg/git/init.go Outdated
@ -14,2 +15,4 @@
if err != nil {
return fmt.Errorf("git init: %s", err)
}
MasterToMain(repo)
Owner

Since Init returns an error, MasterToMain should also do the same to bubble up the errors.

Since `Init` returns an `error`, `MasterToMain` should also do the same to bubble up the errors.
Owner

Also, since the whole idea is to remove the word master, we could do SwitchToMain as the function name?

Also, since the whole idea is to remove the word `master`, we could do `SwitchToMain` as the function name?
Author
Member

ah good idea!

ah good idea!
ammaratef45 marked this conversation as resolved
pkg/git/init.go Outdated
@ -43,2 +46,4 @@
return nil
}
func MasterToMain(repo *git.Repository) {
Owner

I'd really appreciate a unit / integration test for this one! To ensure it works, to avoid regressions etc.

I'd really appreciate a unit / integration test for this one! To ensure it works, to avoid regressions etc.
Author
Member

added, I ran out of spoons during the first draft but should've made it a WIP PR and got back to it rather than submitting it without the test ig

added, I ran out of spoons during the first draft but should've made it a WIP PR and got back to it rather than submitting it without the test ig
ammaratef45 marked this conversation as resolved
pkg/git/init.go Outdated
@ -45,0 +61,4 @@
if err := repo.SetConfig(cfg); err != nil {
log.Fatalf("Failed to update repository config: %v", err)
}
fmt.Println("Set 'main' as the default branch.")
Owner

We normally use slog to do logging? Do you want to do INFO or DEBUG here? You'll see it used elsewhere instead of fmt.Println.

Also, all logging uses lowercase AFAIR, so it's good to follow this convention.

We normally use `slog` to do logging? Do you want to do `INFO` or `DEBUG` here? You'll see it used elsewhere instead of `fmt.Println`. Also, all logging uses lowercase AFAIR, so it's good to follow this convention.
Author
Member

rip, copy-pasting code then forgetting to clean up is embarrassing lol

rip, copy-pasting code then forgetting to clean up is embarrassing lol
ammaratef45 marked this conversation as resolved
ammaratef45 added 1 commit 2024-12-15 02:26:33 +00:00
bubble up errors on branch switch
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
8d076a308a
ammaratef45 changed title from new recipe default branch main instead of master to WIP: new recipe default branch main instead of master 2024-12-15 02:28:47 +00:00
ammaratef45 added 1 commit 2024-12-15 02:41:41 +00:00
add test for SwitchToMain
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
730fef09a3
ammaratef45 changed title from WIP: new recipe default branch main instead of master to new recipe default branch main instead of master 2024-12-15 02:43:20 +00:00
decentral1se reviewed 2024-12-15 14:37:18 +00:00
decentral1se left a comment
Owner

tysm @ammaratef45! LGTM.

I would say one more thing tho. It's up to you, as always.

I am mostly not in favour of keeping these sort of "description of what is happening" comments in the code. And especially on this kind of project which has few "regularly active" maintainers. Things can slip out of understanding very easily and also, things change hands when new people start hacking. That's all good but also, it has disadvantages for code documentation.

The danger is that the comment doesn't represent the code later on when things get changed and nobody feels ownership on the comment or forgets to change it. The comment then misleads future maintainers. I understand this is a bit flame war and personal taste territory but I've already seen comments from long gone maintainers mislead others in this project 🙃

In general, I think a good top-level "doc string" on the function should be enough. It describes "why" and not "what" which is more future proof because you only describe the core of what the code wants to do and this has a greater chance to endure in a more general way and not mislead.

Again, I'm open to argumentation or a decision otherwise but now you know 😌

tysm @ammaratef45! LGTM. I would say one more thing tho. It's up to you, as always. I am mostly not in favour of keeping these sort of "description of what is happening" comments in the code. And especially on this kind of project which has few "regularly active" maintainers. Things can slip out of understanding very easily and also, things change hands when new people start hacking. That's all good but also, it has disadvantages for code documentation. The danger is that the comment doesn't represent the code later on when things get changed and nobody feels ownership on the comment or forgets to change it. The comment then misleads future maintainers. I understand this is a bit flame war and personal taste territory but I've already seen comments from long gone maintainers mislead others in this project 🙃 In general, I think a good top-level "doc string" on the function should be enough. It describes "why" and not "what" which is more future proof because you only describe the core of what the code wants to do and this has a greater chance to endure in a more general way and not mislead. Again, I'm open to argumentation or a decision otherwise but now you know 😌
ammaratef45 added 1 commit 2024-12-15 17:53:39 +00:00
replace code-descriptive comments with method level comments
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
28c7676413
Author
Member

That's a fair concern, and if logs, errors, and variable and function names are readable enough those comments become redundant anyways 🤷‍♀️

That's a fair concern, and if logs, errors, and variable and function names are readable enough those comments become redundant anyways 🤷‍♀️
Owner

@ammaratef45 Nice! Cool, well, feel free to merge whenever 😌

The only other point is that gofmt complains about that style of doc string on the function. If you look at the rest of the functions, you'll see we follow the $NAME ... style. But it's fine, just something to keep in mind in the future.

The CI failure for --- FAIL: TestEnsureDomainsResolveSameIPv4 seems to be related to coop-cloud/abra#448 on a quick glance but I don't have time to dig into it.

@ammaratef45 Nice! Cool, well, feel free to merge whenever 😌 The only other point is that `gofmt` complains about that style of doc string on the function. If you look at the rest of the functions, you'll see we follow the `$NAME ...` style. But it's fine, just something to keep in mind in the future. The CI failure for `--- FAIL: TestEnsureDomainsResolveSameIPv4 ` seems to be related to https://git.coopcloud.tech/coop-cloud/abra/pulls/448 on a quick glance but I don't have time to dig into it.
decentral1se merged commit 28c7676413 into main 2024-12-21 18:11:13 +00:00
decentral1se deleted branch defaultBranch 2024-12-21 18:11:13 +00:00
Sign in to join this conversation.
No description provided.