Commit Messages Generation Based on Core Changes
Yuan Huang, Zhicao Tang, Xiangping Chen, Changlin Yang, Zibin Zheng, Xiaocong Zhou · ACM Transactions on Software Engineering and Methodology · 2025
Commits messages play a crucial role in helping developers efficiently comprehend code modifications. Due to the time pressure of project iteration or poor message-writing practices, many commits suffer from missing messages. To address this issue, researchers have explored the automated generation of commit messages. Because of the truncation mechanism of the learning-based model, most of the current studies focus on code changes appearing at the beginning of a commit into the model for commit message generation. This may not be the best strategy for commit message generation because each code change in a commit contributes unequally to its overall purpose. To better generate commit messages, we propose a novel method that identifies the core code change in a commit for commit message generation. Specifically, we employ a method to predict the relative importance of the classes contained in a commit, and the code change of the class with the highest importance score (i.e., core change) is used to generate the commit message. Incorporating core change information can boost the performance of other existing methods (such as NMT, NNGen, and CoreGen). Building on this insight, we develop CCGen—a Core Change-Based Generation model that integrates a Transformer architecture with CodeBERT-enhanced encoding to leverage code semantics. The experiment demonstrates that the proposed method for commit message generation outperforms the state-of-the-art by 18.47% on average across seven metrics including 19.97 on ROUGE-L.