Abstract Automatic commit message generation is a critical task for maintaining software quality and history. Traditional Neural Machine Translation (NMT) approaches often struggle with the high frequency of out-of-vocabulary (OOV) identifiers and the formal structural nature of source code. This paper introduces CODISUM (Code Diff Summarization), a framework that jointly models the structural "skeleton" and semantic intent of code changes. By employing identifier substitution and a copying mechanism, CODISUM effectively generalizes across projects and accurately reproduces rare identifiers in generated messages. Experimental results on a large-scale Java dataset demonstrate that CODISUM significantly outperforms state-of-the-art baselines in both translation quality and identifier recall.
Introduction
In modern software development, commit messages serve as the primary documentation for the "why" behind code changes. Despite their importance for long-term maintenance and code review, developers frequently neglect them; studies indicate that nearly 14% of commits in prominent open-source projects lack any descriptive text.
Recent efforts to automate this process using Neural Machine Translation (NMT) have encountered two primary obstacles. First, the Out-of-Vocabulary (OOV) problem: source code is replete with project-specific, self-defined identifiers (e.g., ImmutableDomainObjectSet) that standard models cannot process. Second, the Structural Neglect: code is not merely a sequence of tokens but possesses a formal logic and hierarchy. Treating code as plain text ignores the "skeleton" of keywords and operators that define the change's logic.
The CODISUM Framework
CODISUM addresses these challenges by treating commit message generation as a specialized translation task with three core innovations: joint encoding, alignment, and a copying mechanism.
Joint Structure and Semantic Encoding
Rather than processing raw code, CODISUM bifurcates the input into two distinct streams. The Structure stream replaces specific identifiers with generic placeholders (e.g., c0 for a class, n0 for a variable), allowing the model to learn the abstract pattern of a change—such as "adding an interface to a class"—independently of specific naming conventions. Simultaneously, the Semantics stream decomposes complex identifiers into sub-words (e.g., DomainObjectSet into domain, object, set) to capture the developer's underlying intent.
Alignment and Copying Mechanism
The model utilizes Bi-directional Gated Recurrent Units (Bi-GRUs) to encode both streams. A critical insight in the research was that simple concatenation is insufficient; the semantic representation of an identifier must be precisely aligned with its structural placeholder. This creates a rich, dual-layered representation for every token in the diff.
To solve the OOV problem, the decoder does not rely solely on a fixed vocabulary. Instead, it can "copy" a placeholder from the input structure directly into the output message. Once the message is generated, these placeholders are swapped back for the original identifiers.
Experimental Evaluation
The researchers evaluated CODISUM using a large-scale dataset of 1,000 popular Java projects from GitHub. After rigorous pre-processing to remove non-Java files and duplicates, the final dataset comprised 90,661 pairs of code diffs and commit messages, split into training (75,000), validation (8,000), and testing (7,661) sets.
CODISUM was compared against standard NMT, a retrieval-based approach (NNGen), and a text summarization model (CopyNet). CODISUM consistently outperformed all competitors in BLEU and METEOR scores. Most notably, it achieved an Identifier Recall of 33.96%, a massive improvement over the 2.98% recall of standard NMT models. Ablation studies confirmed that both the copying mechanism and structural modeling are essential for this performance.
Conclusion and Future Work
CODISUM demonstrates that the logic of a commit is often independent of specific variable names. By abstracting names into placeholders, the model generalizes effectively across diverse projects. While the current model relies on a "skeleton" approach, future work could incorporate full Abstract Syntax Trees (ASTs) to provide even deeper structural insights. Additionally, integrating global project context beyond the immediate code diff could further enhance the accuracy and relevance of generated messages.
Summary updated