8000 Feat: Display lineage / hierarchy for Proposals by Ydot19 · Pull Request #4871 · git-town/git-town · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feat: Display lineage / hierarchy for Proposals #4871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ydot19
Copy link
@Ydot19 Ydot19 commented May 7, 2025

No description provided.

@Ydot19 Ydot19 changed the title Support pull requests comments Feat: Display lineage / hierarchy for Proposals May 7, 2025
Copy link
Contributor
@kevgo kevgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this nice feature - great work! 🙏

You're definitely heading in the right direction. My main feedback at this stage is to approach this using the "spike and stabilize" method: start by getting a simple prototype working (the spike), and once that’s in place, we can refine it (stabilize) by adding the necessary checks, patterns, and types to make it production-ready.

In general, I find that good abstractions and patterns emerge naturally from working code rather than being designed upfront.

This approach should help us keep sight of the bigger picture as we iterate. I'm excited to see the next iteration of this!

@@ -19,31 +19,40 @@ import (
)

const (
branchDesc = "Display the local branch hierarchy and types"
branchDesc = `
Display hierarchy either for local branches or an existing proposal of stack.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Display hierarchy either for local branches or an existing proposal of stack.
Display hierarchy either for local branches or an existing stack of proposals.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request makes two large changes:

  1. add --lineage to git town propose to update the displayed lineage in the proposal
  2. add --lineage to git town branch to display the branch lineage based on pull request information in the CLI

I suggest you implement each change in a separate pull request. For this one, let's focus on (1). Change (2) is a good idea but requires additional brainstorming, which we best do in an issue.

8000
readFlag := func(cmd *cobra.Command) (configdomain.ProposalLineage, error) {
value, err := cmd.Flags().GetBool(proposalLineageLong)
if err == nil && value {
return enabledAction, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it return true here, given that the user provided the CLI flag? CLI flags take precedence over any other form of configuration.

Comment on lines +6 to +8
ProposalLineageNone ProposalLineage = "none"
ProposalLineageComment ProposalLineage = "comment"
ProposalLineageTerminalDisplay ProposalLineage = "terminal-display"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of all the custom types in this package is to make invalid states unrepresentable in the codebase. This eliminates entire categories of bugs.

With this in mind, this enum allows invalid states:

  • ProposalLineageTerminalDisplay isn't a valid value for git town propose --lineage.
  • ProposalLineageComment isn't a valid value for git town branch --lineage.

I suggest you split this custom type up into two separate custom types, where each wraps bool.

Comment on lines +9 to +10
ProposalCommentSortByCreatedAt ProposalCommentSortBy = "created_at"
ProposalCommentSortByUpdatedAt ProposalCommentSortBy = "updated_at"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need a custom type here. We're not passing this value around extensively, it's only used to provide the "created_at" field to the GitHub connector. We don't use "updated_at" at all.

Our goal here isn't building a general-purpose GitHub connector; we're using the existing one to load proposal comments. I suggest keeping things simple for now: focus on getting a minimal version of the idea working by hard-coding things like "created_at" and "limit" for now.

Once the prototype is in place, we can review the code and look for patterns that want to emerge from the code base, like custom types, structs, or helper functions.

Does that sound reasonable?

@@ -165,6 +186,63 @@ func (self Connector) squashMergeProposal(number int, message gitdomain.CommitMe
return err
}

func (self Connector) getProposalComments(number int, configurations ...forgedomain.ConfigureProposalCommentQueryOptions) (Option[[]gitdomain.Comment], error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only use two arguments for now (limit and sort-by), and actually always use the same values for each, I'd be okay keeping it simple and hard-coding them for now.

Suggested change
func (self Connector) getProposalComments(number int, configurations ...forgedomain.ConfigureProposalCommentQueryOptions) (Option[[]gitdomain.Comment], error) {
func (self Connector) getProposalComments(proposalID int) (Option[[]gitdomain.Comment], error) {
// use "created_at" and 1 for sorting and limit

Comment on lines +190 to +192
if number <= 0 {
return None[[]gitdomain.Comment](), errors.New(messages.ProposalNoNumberGiven)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is necessary, since we always use proposal numbers returned by the GitHub API. If we do want to enforce that proposal numbers are > 0, a better approach might be to introduce a custom forgedomain.ProposalNumber type with a constructor that validates this constraint.

That way we avoid repeating this check in multiple places. It also helps surface errors closer to the source if an invalid proposal number is ever constructed.

@@ -0,0 +1,7 @@
package gitdomain

type CommentBody string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this custom type is needed yet. When in doubt, leave it out 🙂

@kevgo
Copy link
Contributor
kevgo commented May 7, 2025

You can run make fix to fix the linter errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0