nephio-project / nephio

Nephio is a Kubernetes-based automation platform for deploying and managing highly distributed, interconnected workloads such as 5G Network Functions, and the underlying infrastructure on which those workloads depend.
Apache License 2.0
107 stars 53 forks source link

Enable auto squashing of commits in GitHub #132

Closed gvbalaji closed 1 year ago

gvbalaji commented 1 year ago

A PR could potentially contain multiple commts. Squashing all the commits before merging could maintain a cleaner history of code changes.

@SimonTheLeg has shown how this can be done automatically in GitHub and how PR title and description could be used as final commit messages. It also maintains the names of all authors.

Once we get a wider buy in for this , we can implement it for all nephio repos.

johnbelamaric commented 1 year ago

Yes please!

Multiple commits are super useful during review time ("show changes since your last review" and even better, if people organize the commits logically). But squashing would be best for the final merge.

gvbalaji commented 1 year ago

From @SimonTheLeg

  1. What is possible on Github? These are the options in Github:

https://docs.google.com/document/d/1SW4acc0950QdDNEvmeHArfNsgKPeY_EIwHBqGBky2CY/edit#bookmark=kix.hcx7q6l4m9lj

  1. What is possible in prow? Within tide (component in prow), we can set it up to use “squash” as the merge_method (refer to https://docs.prow.k8s.io/docs/components/core/tide/config/) Apart from this, prow does not have any additional capabilities for squash merging. Instead it simply calls the GitHub-API, which then does what is configured in the repo.

  2. How do we handle a PR which has commits from multiple authors? Github handles this automatically by adding a Co-authored by xyz line to the commit message. This is then displayed in the UI and persisted in git-history:

(example taken from https://github.com/kubermatic/kubermatic/commit/022ca1e74a2aec8636fb77079433daa97c8b7a25)

radoslawc commented 1 year ago

We can have both, actually all three options really (merge, squash, rebase). Tide has configuration option to have designated labels make it switch merging type. If you label PR with (label name is configurable) let's say 'tide/merge-method-squash' it will squash commits and and github automatically preserves authors as coauthors and commit message is concatenated from included commits.

radoslawc commented 1 year ago

After some thinking, let's make squash default method.

gvbalaji commented 1 year ago

Thanks @radoslawc . I assume this is done now. Does it use PR message and description as commit messages?