Software source code difference automatic comparison method

By using tools such as Git and GitLab, the source code differences between different versions of the large software systems are automated, and the problems that developers and project managers need to frequently compare the source code of the source code, and achieve efficient and accurate analysis and statistical report generation.

CN119376782APending Publication Date: 2025-01-28NANJING RES INST OF ELECTRONICS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411444166.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

During the research and development of large software systems, developers and project managers need to frequently view the source code differences of different versions, conduct hidden danger investigation and workload statistics, but due to the huge code scale and the large number of participants, it takes great effort to achieve this requirement manually. Large management costs.

Method used

Proposal to automatically compare the software source differences. Using the distributed project management system Git and version library server Gitlab, through the establishment of an automatic comparison task, the source code file difference is compared, the difference is generated, and the report is analyzed statistically to generate statistical reports.

Benefits of technology

The comparison of the source code difference of automation, reducing the time and cost of manual comparison, improving the efficiency and accuracy of project management, and helping the project development progress.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376782A_ABST
    Figure CN119376782A_ABST
Patent Text Reader

Abstract

The invention discloses a software source code difference automatic comparison method, which comprises the following steps of: managing software research and development projects by using a distributed project management system Git to form a Git version library of the software research and development projects, and managing the Git version library of the software research and development projects by using a version library server Gitlab; establishing a source code difference automatic comparison task; performing source code file difference comparison to generate a difference report; and performing statistical analysis on the difference report to generate a statistical report. According to the method adopted by the invention, correct results can be fed back to developers and project managers in forms of reports and reports; obvious benefits are achieved in the aspects of execution time, resource consumption, manpower consumption and the like; and management and control of project management order and project development progress are facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of automated software technology, and in particular relates to a method for automatically comparing software source code differences. Background Art

[0002] Modern large-scale information software systems are usually developed in stages by a large number of developers and managers. This development model greatly increases the difficulty of configuration management during the software development process, especially in the comparative analysis of differences between different versions of code. There are two urgent needs:

[0003] 1) During the development process, developers need to frequently check the differences between different versions of source code, so as to timely troubleshoot potential problems in the development process and clearly understand their own development progress.

[0004] 2) From the perspective of project management, project managers need to pay attention to changes in the project source code content, so as to quantify and analyze the software development workload of each developer. This is the basis for conducting quantitative analysis of software project management.

[0005] When the software code is huge and involves a large number of developers, manually achieving the above two requirements requires huge management costs. Therefore, an automatic comparison method for software source code differences is an urgent need for quantitative management of collaborative R&D of large software teams. Summary of the invention

[0006] In order to solve the above problem, the present invention proposes a method for automatically comparing software source code differences, comprising the following steps:

[0007] Use the distributed project management system Git to manage software development projects to form the Git version library of the software development projects, and use the version library server Gitlab to manage the Git version library of the software development projects;

[0008] Establish automatic source code difference comparison task;

[0009] Compare source code files and generate difference reports;

[0010] Perform statistical analysis on the difference reports and generate statistical reports.

[0011] Furthermore, the management of the Git version library of the software development project by the version library server Gitlab includes Git project creation and user configuration.

[0012] Furthermore, according to the software development requirements and development plan, automatic tasks of the software development project are set in the form of scripts, and the automatic tasks are automatically executed by the continuous integration CI server at a fixed time.

[0013] Furthermore, the continuous integration CI server realizes the status monitoring and operation of the Git version library of the software development project through plug-in links.

[0014] Furthermore, before comparing the differences in source code files, a version search is performed first, the version number is searched according to the version backtracking date, and the version at that time is backtracked according to the version number; the current version and the version at that time are put into Now and Forword respectively.

[0015] Furthermore, performing version retrieval specifically includes the following steps:

[0016] Set the Now version directory and copy the current version to Now to filter unnecessary files;

[0017] Set the Forword version directory;

[0018] Calculate the lookback date based on the number of lookback days entered;

[0019] Search for version numbers based on Git Log;

[0020] Retrieve versions by version number;

[0021] The retrieved version is copied to Forword and unnecessary files are filtered, including system files.

[0022] Furthermore, source code file differences are compared and a difference report is generated, which specifically includes the following steps:

[0023] Input parameters, including the Now version directory, Forword version directory, report format parameters, and report storage directory Reports; Now version directory

[0024] Writing differential execution into a script to form a differential execution script;

[0025] Traverse all the files that need to be compared;

[0026] Execute the differential execution script after calling BeyondCompare;

[0027] Generate a difference report and save it;

[0028] Traverse all difference reports and perform statistical calculations; the statistical calculations include important difference lines, etc.

[0029] Compared with the prior art, the present invention has the following advantages:

[0030] (1) The present invention aims at two main requirements in the process of software system development: developers need to frequently check the source code differences between different versions, and project managers also need to pay attention to the changes in the project source code content and count the amount of changes. An automatic source code difference comparison method is proposed.

[0031] (2) The present invention can provide correct results to developers and project managers in the form of tables and reports. It has obvious benefits in terms of execution time, resource consumption, manpower consumption, etc. It helps to control the project management order and project development progress. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 This is an automatic comparison framework for software source code differences according to an embodiment of the present invention.

[0033] Figure 2 This is the automatic comparison process of software source code differences in an embodiment of the present invention.

[0034] Figure 3 This is the version retrieval process of an embodiment of the present invention.

[0035] Figure 4 This is the difference report generation and statistical process of the embodiment of the present invention.

[0036] Figure 5 This is the statistical result of the engineering catalog of the embodiment of the present invention.

[0037] Figure 6 The difference contents of the source code Example1.cpp of the embodiment of the present invention are detailed.

[0038] Figure 7 The difference contents of the source code Example2.cpp of the embodiment of the present invention are detailed.

[0039] Figure 8 The difference contents of the source code Example3.cpp of the embodiment of the present invention are detailed.

[0040] Fig. 9 The difference contents of the source code Example7.cpp of the embodiment of the present invention are detailed. DETAILED DESCRIPTION

[0041] The purpose of the present invention is to provide a technology that can automatically retrieve the corresponding software source code version according to the input version backdating date, and automatically compare the source code of the current version and the historical version, calculate the number of difference code lines, and generate a difference report.

[0042] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.

[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0044] It can be understood that the terms "first", "second", etc. used in the present application can be used in this article to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element.

[0045] Spatially relative terms such as "under," "beneath," "below," "under," "above," "above," and the like may be used herein to describe the relationship of an element or feature shown in the figures to other elements or features. It should be understood that, in addition to the orientations shown in the figures, spatially relative terms also include different orientations of the device in use and operation. For example, if the device in the accompanying drawings is flipped, an element or feature described as "under other elements" or "under it" or "under it" will be oriented as being "above" the other elements or features. Thus, the exemplary terms "under" and "under" may include both upper and lower orientations. In addition, the device may also include additional orientations (e.g., rotated 90 degrees or other orientations), and the spatial descriptors used herein are interpreted accordingly.

[0046] It should be noted that when an element is considered to be "connected" to another element, it can be directly connected to the other element, or connected to the other element through an intermediate element. In addition, the "connection" in the following embodiments should be understood as "electrical connection", "communication connection", etc. if there is transmission of electrical signals or data between the connected objects.

[0047] When used herein, the singular forms "a", "an", and "said / the" may also include plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "include / comprise" or "have" and the like specify the presence of stated features, wholes, steps, operations, components, parts, or combinations thereof, but do not exclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts, or combinations thereof. At the same time, the term "and / or" used in this specification includes any and all combinations of the relevant listed items.

[0048] In order to make the purpose, technical solution and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0049] The method for automatically comparing software source code differences in this embodiment can be summarized as follows: using the distributed project management system Git as a management tool for software development projects to form a Git version library for the software development project, and uniformly handing over the project's Git version library to the version library server Gitlab for management, and using Git Log for version retrieval. Using comparison tools such as BeyondCompare, compare source code file differences and generate reports. Design and develop statistical calculation programs, perform statistical analysis on difference reports, and generate Excel reports. Establish automatic execution tasks in the form of scripts. Finally, the continuous integration CI server executes automatic integration tasks on a regular basis. Technical architecture design and process such as Figure 1 and Figure 2 As shown, it includes 4 main components:

[0050] 1) Distributed project management. The distributed project management system Git is used to manage projects in the software development process. The Git version library allows each developer to save a complete image, including all historical records, to achieve collaborative development while avoiding single point of failure. The version library server Gitlab is used for Git project creation, user configuration and other management tasks.

[0051] 2) Automatic comparison task. Establish an automatic source code difference comparison task. According to the software development requirements and development plan, set the automatic tasks of the software development project in the form of scripts, and assign them to the continuous integration CI server for scheduled automatic execution. Among them, the continuous integration CI server is used to manage the task scheduler of the operating system, and through plug-in links, it can realize the status monitoring and operation of the Git version library of the software development project. The continuous integration CI server interacts with the version library managed by Git through the Git plugin interface.

[0052] 3) Version search. Enter the version backdating date and search for the version number according to Git Log. Use the version number to backtrack to the required version status. The process is as follows Figure 3 As shown, the specific steps include:

[0053] Set the Now version directory, copy the current version to Now to filter unnecessary files, including system files;

[0054] Set the Forword version directory;

[0055] Calculate the lookback date based on the number of lookback days entered;

[0056] Search for version numbers based on Git Log;

[0057] Retrieve versions by version number;

[0058] Copy the retrieved versions to Forword to filter out unnecessary files.

[0059] 4) Generation and statistics of difference reports.

[0060] Put the current version and the version to be compared into Now and Forword respectively. The automatic difference comparison task calls BeyondCompare, and generates a difference report with the current version Now as the reference directory. Design and develop a statistical calculation program, perform statistical analysis on the difference report, and generate an Excel report, in which the newly added source code files are directly counted. The process is as follows Figure 4 As shown, the specific steps include:

[0061] Input parameters, including Now version directory, Forword version directory, report format parameters, and report storage directory Reports;

[0062] Writing differential execution into a script to form a differential execution script;

[0063] Traverse all the files that need to be compared;

[0064] Execute the differential execution script after calling BeyondCompare;

[0065] Generate a difference report and save it;

[0066] Traverse all difference reports and perform statistical calculations; the statistical calculations include important difference lines, etc.

[0067] This embodiment is applied in the development process of a certain software system, and the following process is designed and implemented as an application example. Focus on the correctness of the difference results, and focus on indicators such as task time consumption and resource usage during the implementation process.

[0068] 1) Configure the hardware server environment and operating system. In this example, the development environment, server environment, operating system, etc. all use domestic products. Deploy tools such as Jenkins, git, and gitlab to build the basic environment.

[0069] 2) Create an implementation example project, create an automatic difference comparison task, and set the backtracking period to 10 days. Execute the task, count the code changes and the number of changed lines, and write a report. Figure 5 , Figure 6 , Figure 7 , Figure 8 , Fig. 9shown. Figure 5 The source code files in the project directory of the embodiment are shown, wherein the sum column is the statistical result of the number of difference lines between the two versions. Figure 6 The difference content of the source code Example1.cpp is detailed; Figure 7 The difference content of the source code Example2.cpp is detailed; Figure 8 The difference content of the source code Example3.cpp is detailed; Fig. 9 The difference content of the source code Example7.cpp is detailed; Figure 6 , Figure 7 , Figure 8 , Fig. 9 The red part is the difference between the two versions, and the number of lines is Figure 5 The numbers in correspond to the task execution success and the result is correct.

[0070] The present invention aims at the two main requirements in the process of software system development: developers need to frequently check the source code differences of different versions, and project managers also need to pay attention to the changes in the project source code content and count the amount of changes. An automatic source code difference comparison method is proposed. Through the use of this method, the correct results can be fed back to developers and project managers in the form of statements and reports; there are obvious benefits in terms of execution time, resource consumption, manpower consumption, etc.; it is helpful to control the project management order and project development progress.

[0071] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for automatically comparing software source code differences, characterized in that: The following steps are involved: Use the distributed project management system Git to manage software development projects to form the Git version library of the software development projects, and use the version library server Gitlab to manage the Git version library of the software development projects; Establish automatic source code difference comparison task; Compare source code files and generate difference reports; Perform statistical analysis on the difference reports and generate statistical reports.

2. The method for automatically comparing software source code differences according to claim 1, characterized in that: The version library server Gitlab manages the Git version library of software development projects, including Git project creation and user configuration.

3. The method for automatically comparing software source code differences according to claim 1, characterized in that: According to the software development requirements and development plan, automatic tasks of the software development project are set in the form of scripts, and the automatic tasks are automatically executed by the continuous integration CI server at a fixed time.

4. The method for automatically comparing software source code differences according to claim 3, characterized in that: The continuous integration CI server uses plug-in links to monitor and run the status of the Git version library of the software development project.

5. The method for automatically comparing software source code differences according to claim 1, characterized in that: Before comparing the differences in source code files, perform version search first, find the version number based on the version backdating date, and backtrack to the version at that time based on the version number; put the current version and the version at that time into Now and Forword respectively.

6. The method for automatically comparing software source code differences according to claim 5, characterized in that: The version retrieval process includes the following steps: Set the Now version directory and copy the current version to Now to filter unnecessary files; Set the Forword version directory; Calculate the lookback date based on the number of lookback days entered; Search for version numbers based on Git Log; Retrieve versions by version number; The retrieved version is copied to Forword and unnecessary files are filtered, including system files.

7. The method for automatically comparing software source code differences according to claim 6, characterized in that: Compare the source code files and generate a difference report, which includes the following steps: Input parameters, including the Now version directory, Forword version directory, report format parameters, and report storage directory Reports; Now version directory Writing differential execution into a script to form a differential execution script; Traverse all the files that need to be compared; Execute the differential execution script after calling BeyondCompare; Generate a difference report and save it.