Leveraging Context-Aware Prompting for Commit Message Generation

Zhihua Jiang, Jianwei Chen, Dongning Rao, Guanghui Ye


Abstract
Writing comprehensive commit messages is tedious yet important, because these messages describe changes of code, such as fixing bugs or adding new features. However, most existing methods focus on either only the changed lines or nearest context lines, without considering the effectiveness of selecting useful contexts. On the other hand, it is possible that introducing excessive contexts can lead to noise. To this end, we propose a code model COMMIT (Context-aware prOMpting based comMIt-message generaTion) in conjunction with a code dataset CODEC (COntext and metaData Enhanced Code dataset). Leveraging program slicing, CODEC consolidates code changes along with related contexts via property graph analysis. Further, utilizing CodeT5+ as the backbone model, we train COMMIT via context-aware prompt on CODEC. Experiments show that COMMIT can surpass all compared models including pre-trained language models for code (code-PLMs) such as CommitBART and large language models for code (code-LLMs) such as Code-LlaMa. Besides, we investigate several research questions (RQs), further verifying the effectiveness of our approach. We release the data and code at: https://github.com/Jnunlplab/COMMIT.git.
Anthology ID:
2024.emnlp-main.749
Volume:
Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing
Month:
November
Year:
2024
Address:
Miami, Florida, USA
Editors:
Yaser Al-Onaizan, Mohit Bansal, Yun-Nung Chen
Venue:
EMNLP
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
13522–13540
Language:
URL:
https://aclanthology.org/2024.emnlp-main.749
DOI:
Bibkey:
Cite (ACL):
Zhihua Jiang, Jianwei Chen, Dongning Rao, and Guanghui Ye. 2024. Leveraging Context-Aware Prompting for Commit Message Generation. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pages 13522–13540, Miami, Florida, USA. Association for Computational Linguistics.
Cite (Informal):
Leveraging Context-Aware Prompting for Commit Message Generation (Jiang et al., EMNLP 2024)
Copy Citation:
PDF:
https://aclanthology.org/2024.emnlp-main.749.pdf
Software:
 2024.emnlp-main.749.software.zip
Data:
 2024.emnlp-main.749.data.zip