Skip to content

Commit bb50402

Browse files
authored
Merge pull request #208 from sysprog21/git-best-practice
Enhance Git commit style
2 parents 3882f60 + 2108bce commit bb50402

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

CONTRIBUTING.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,50 @@ to `memset()` structures with zero. Non-zero `NULL` is for retro computing.
791791
792792
## Git Commit Style
793793
794-
Clear and descriptive commit messages are crucial for maintaining a transparent history of changes and for facilitating effective debugging and tracking. Please adhere to the guidelines outlined in [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/).
794+
Effective version control is critical to modern software development.
795+
Git's powerful features—such as granular commits, branching,
796+
and a versatile staging area—offer unparalleled flexibility.
797+
However, this flexibility can sometimes lead to disorganized commit histories and
798+
merge conflicts if not managed with clear, consistent practices.
799+
800+
By committing often, writing clear messages, and adhering to a common workflow,
801+
developers can not only reduce the potential for errors but also simplify collaboration and future maintenance.
802+
We encourage every team to tailor these best practices to their specific needs while striving
803+
for a shared standard that promotes efficiency and code quality.
804+
805+
Below are the detailed guidelines that build on these principles.
806+
* Group Related Changes Together
807+
Each commit should encapsulate a single, coherent change.
808+
e.g., if you are addressing two separate bugs, create two distinct commits.
809+
This approach produces focused, small commits that simplify understanding, enable quick rollbacks,
810+
and foster efficient peer reviews.
811+
By taking advantage of Git’s staging area and selective file staging,
812+
you can craft granular commits that make collaboration smoother and more transparent.
813+
* Commit Frequently
814+
Making commits often ensures that your changes remain concise and logically grouped.
815+
Frequent commits not only help maintain a clean history but also allow you to share your progress with your teammates regularly.
816+
This regular sharing keeps everyone in sync,
817+
minimizes merge conflicts, and promotes a collaborative environment where integration happens seamlessly.
818+
* Avoid Committing Work in Progress
819+
Only commit code when a logical component is in a stable, ready-to-integrate state.
820+
Break your feature's development into manageable segments that reach a functional milestone quickly,
821+
so you can commit regularly without compromising quality.
822+
If you feel the urge to commit merely to clear your working directory for actions like switching branches or pulling changes,
823+
use Git's stash feature instead.
824+
This practice helps maintain a stable repository and ensures that your team reviews well-tested, coherent code.
825+
* Test Your Code Before Committing
826+
Before committing, ensure that your code has been thoroughly tested.
827+
Rather than assuming your changes are ready, run comprehensive tests to confirm they work as intended without unintended side effects.
828+
Testing is especially critical when sharing your code with others,
829+
as it maintains the overall stability of the project and builds trust among collaborators.
830+
* Utilize Branches for Parallel Development
831+
Branches are a powerful tool that enables developers to isolate different lines of work—whether you are developing new features,
832+
fixing bugs, or exploring innovative ideas.
833+
By using branches extensively, you can work on your tasks independently and merge only after careful review and testing.
834+
This not only keeps the main branch stable but also encourages collaborative code reviews and a more organized integration process.
835+
836+
Clear and descriptive commit messages are crucial for maintaining a transparent history of changes and for facilitating effective debugging and tracking.
837+
Please adhere to the guidelines outlined in [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/).
795838
1. Separate the subject from the body with a blank line.
796839
2. Limit the subject line to 50 characters.
797840
3. Capitalize the subject line.
@@ -801,7 +844,6 @@ Clear and descriptive commit messages are crucial for maintaining a transparent
801844
7. Use the body to explain what and why, not how.
802845

803846
An example (derived from Chris' blog post) looks like the following:
804-
805847
```text
806848
Summarize changes in around 50 characters or less
807849
@@ -830,6 +872,34 @@ like this:
830872
Close #123
831873
```
832874

875+
Another illustration of effective practice.
876+
```text
877+
commit f1775422bb5a1aa6e79a685dfa7cb54a852b567b
878+
Author: Jim Huang <[email protected]>
879+
Date: Mon Feb 24 13:08:32 2025 +0800
880+
881+
Introduce CPU architecture filtering in scheduler
882+
883+
In environments with mixed CPU architectures, it is crucial to ensure
884+
that an instance runs only on a host with a compatible CPU
885+
type—preventing, for example, a RISC-V instance from being scheduled on
886+
an Arm host.
887+
888+
This new scheduler filter enforces that requirement by comparing an
889+
instance's architecture against the host's allowed architectures. For
890+
the libvirt driver, the host's guest capabilities are queried, and the
891+
permitted architectures are recorded in the permitted_instances_types
892+
list within the host's cpu_info dictionary.
893+
894+
The filter systematically excludes hosts that do not support the
895+
instance's CPU architecture. Additionally, RISC-V has been added to the
896+
set of acceptable architectures for scheduling.
897+
898+
Note that the CPU architecture filter is disabled by default.
899+
```
900+
901+
The above is a clear, unformatted description provided in plain text.
902+
833903
In addition, this project expects contributors to follow these additional rules:
834904
* If there is important, useful, or essential conversation or information,
835905
include a reference or copy it.

scripts/aspell-pws

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,9 @@ SIGTERM
332332
SIGTRAP
333333
SIGUSR
334334
SIGWINCH
335+
risc
336+
mips
337+
riscv
338+
info
339+
cpu
340+
libvirt

0 commit comments

Comments
 (0)