Code change analysis method, electronic equipment and readable storage medium

By comparing the baseline relationship diagram of the Java code and the change version relationship map, combined with the large language model, automatically analyzes the code change, solve the problem of low efficiency of manual analysis, and achieve efficient and accurate code change analysis.

CN119336600APending Publication Date: 2025-01-21CHINA MERCHANTS SECURITIES CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411285822.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-13
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

Java code change analysis relies on manual analysis, which leads to inefficiency and error-prone.

Method used

By obtaining the baseline version diagram, change version diagram and source code library of the program to be analyzed, compare the two to obtain version change data, and use the preset large language model to generate a code change analysis summary based on the differential source code and code change relationship.

Benefits of technology

It realizes automatic analysis of code changes, improves the efficiency of change analysis, and reduces the error rate of manual analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336600A_ABST
    Figure CN119336600A_ABST
Patent Text Reader

Abstract

The invention discloses a code change analysis method, electronic equipment and a readable storage medium, and relates to the technical field of codes, and the code change analysis method comprises the steps of obtaining a baseline version relation graph, a change version relation graph and a source code library of a to-be-analyzed program; comparing the baseline version relation graph with the changed version relation graph to obtain version change data, the version change data at least comprising one of a code change relation and a code change method; obtaining a difference source code of the code change method from the source code library; and calling a preset large language model, and determining a code change analysis abstract of the to-be-analyzed program according to the difference source code and the code change relationship. The technical problem that the adjustment of the abstract analysis rule is not timely enough is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of business processing technology, and in particular to a code change analysis method, an electronic device, and a readable storage medium. Background Art

[0002] In the Java field, code change analysis mainly relies on manual analysis. For example, analysts are required to sort out the change points in the code one by one and manually enter the changed code. This is not only tedious and time-consuming, but also prone to errors, making code change analysis inefficient.

[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0004] The main purpose of this application is to provide a code change analysis method, an electronic device and a readable storage medium, aiming to solve the technical problem of low efficiency of code change analysis.

[0005] To achieve the above objectives, the present application provides a code change analysis method, comprising:

[0006] Obtain the baseline version relationship diagram, changed version relationship diagram and source code library of the program to be analyzed;

[0007] Comparing the baseline version relationship diagram with the changed version relationship diagram to obtain version change data, wherein the version change data includes at least one of a code change relationship and a code change method;

[0008] Obtaining the differential source code of the code change method from the source code library;

[0009] A preset large language model is called to determine a code change analysis summary of the program to be analyzed according to the difference source code and the code change relationship.

[0010] In one embodiment, the step of obtaining a baseline version relationship diagram and a changed version relationship diagram of the program to be analyzed includes:

[0011] Obtain the baseline version release package and the changed version release package of the program to be analyzed;

[0012] Calling the code parsing component to parse the baseline version release package and the modified version release package respectively, obtaining the first element relationship between each first code element of the baseline version release package and each first code element, and obtaining the second element relationship between each second code element of the modified version release package and each second code element;

[0013] Determine a first hash value for each of the first code elements in the baseline version release package, and determine a second hash value for each of the second code elements in the changed version release package;

[0014] A baseline version relationship graph is constructed in a graph database according to the first element relationship, each of the first code elements and their respective first hash values, and a change version relationship graph is constructed according to the second element relationship, each of the second code elements and their respective second hash values.

[0015] In one embodiment, the step of comparing the baseline version relationship graph and the changed version relationship graph to obtain version change data includes:

[0016] According to each first hash value in the baseline version relationship graph and each second hash value in the change version relationship graph, the baseline version relationship graph and the change version relationship graph are compared to obtain a code change method;

[0017] According to the first element relationship in the baseline version relationship graph and the second element relationship in the change version relationship graph, the baseline version relationship graph and the change version relationship graph are compared to obtain a code change relationship.

[0018] In one embodiment, the first code element includes a first method and the second code element includes a second method;

[0019] The step of comparing the baseline version relationship graph and the changed version relationship graph according to each first hash value in the baseline version relationship graph and each second hash value in the changed version relationship graph to obtain the code change method comprises:

[0020] Comparing the baseline version relationship graph with the changed version relationship graph, if the baseline version relationship graph contains a target deletion first Hash value deleted in the changed version relationship graph, determining that the code change method includes a target deletion first method of deleting the target deletion first Hash value;

[0021] If there is a target change second hash value in the change version relationship graph that is different from each of the first hash values ​​in the baseline version relationship graph, determining whether there is a method signature for the target change second hash value in the baseline version relationship graph;

[0022] If the method signature of the target change second hash value does not exist in the baseline version relationship graph, determining that the code change method includes the target change second method of the target change second hash value;

[0023] If a method signature of the target change second hash value exists in the baseline version relationship graph, a target change first method identical to the method signature is determined in the baseline version relationship graph, and a first bytecode of the target change first method and a second bytecode of the target change second method are obtained;

[0024] In the case that there is a functional difference between the first bytecode and the second bytecode, determining that the code change method includes the target change first method and the target change second method, the functional difference is characterized by a difference between a first parameter called by the first bytecode and a second parameter called by the second bytecode.

[0025] In one embodiment, the step of comparing the baseline version relationship graph and the changed version relationship graph according to the first element relationship in the baseline version relationship graph and the second element relationship in the changed version relationship graph to obtain the code change relationship includes:

[0026] comparing the first element relationship and the second element relationship, and determining, in the second element relationship, an interface call change relationship that is different from the first element relationship;

[0027] A call change interface is determined from the interface call change relationship, an interface call chain of the call change interface is determined in the second element relationship, and the interface call chain is used as a code change relationship.

[0028] In one embodiment, the difference source code includes at least one sub-source code, and the sub-source code is the first difference source code, the second difference source code, or the first deleted source code;

[0029] The step of obtaining the differential source code of the code change method from the source code library includes:

[0030] In a case where the code change method includes a target deletion first method, obtaining a first deletion source code of the target deletion first method in the baseline source code of the source code library according to the first start and end lines of the target deletion first method;

[0031] In a case where the code change method includes a first target change method, obtaining a first difference source code of the first target change method in the baseline source code of the source code library according to the second start and end lines of the first target change method;

[0032] In the case where the code change method includes a second target change method, a second difference source code of the second target change method is obtained from the changed source code of the source code library according to the third start and end lines of the second target change method.

[0033] In one embodiment, the code change analysis summary includes a method business change summary and a relationship business change summary;

[0034] The step of calling the preset large language model to generate a code change analysis summary of the difference source code and the code change relationship includes:

[0035] Generate a business change analysis prompt statement according to a preset business change analysis prompt template, the difference source code, and the class name corresponding to the difference source code;

[0036] Input the business change analysis prompt statement into a preset large language model to obtain the code change content output by the preset large language model and the method business change summary of the code change content;

[0037] Generate an interface change analysis prompt statement according to a preset interface change analysis prompt template and the code change relationship;

[0038] The interface change analysis prompt statement is input into a preset large language model to obtain an interface change summary of the code change relationship.

[0039] In one embodiment, after the step of inputting the interface change analysis prompt statement into a preset large language model to obtain the interface change summary of the code change relationship, the following step is further included:

[0040] Obtain code change requirement information of the program to be analyzed, and call a preset large language model to generate a requirement summary of the code change requirement information;

[0041] The requirement summary, code change analysis summary, code business change content, and code change relationship of the program to be analyzed are used as a code change analysis report of the program to be analyzed.

[0042] In addition, to achieve the above purpose, the present application also provides a code change analysis device, including:

[0043] A first acquisition module is used to acquire a baseline version relationship diagram, a changed version relationship diagram, and a source code library of the program to be analyzed;

[0044] A comparison module, configured to compare the baseline version relationship diagram with the changed version relationship diagram to obtain version change data, wherein the version change data includes at least one of a code change relationship and a code change method;

[0045] A second acquisition module is used to acquire the difference source code of the code change method from the source code library;

[0046] The calling module is used to call a preset large language model and determine a code change analysis summary of the program to be analyzed according to the difference source code and the code change relationship.

[0047] In addition, to achieve the above-mentioned purpose, the present application also provides an electronic device, which includes: a memory, a processor, and a program of the code change analysis method stored in the memory and executable on the processor. When the program of the code change analysis method is executed by the processor, the steps of the code change analysis method as described above can be implemented.

[0048] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which is stored a program for implementing the code change analysis method, and when the program of the code change analysis method is executed by a processor, the steps of the code change analysis method as described above are implemented.

[0049] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned code change analysis method when executed by a processor.

[0050] One or more technical solutions proposed in the present application have at least the following technical effects: since the present application can compare the baseline version relationship diagram and the changed version relationship diagram of the code to be analyzed to obtain the version difference data of the code to be analyzed, the code change relationship and the code change method in the code to be analyzed can be automatically determined by comparing the baseline version relationship diagram and the changed version relationship diagram, and then the difference source code of the code change method in the version difference data is obtained from the source code library, and the preset large language model is called to determine the code change analysis summary of the program to be analyzed according to the difference source code and the code change relationship, thereby realizing automatic analysis of the changes of the program to be analyzed without manual analysis, thereby improving the change analysis efficiency of the code to be analyzed. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the description, are used to explain the principles of the present application.

[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0053] Figure 1 This is a flow chart of an embodiment of a code change analysis method of the present application;

[0054] Figure 2 This is a schematic diagram of the structure of an embodiment of the code change analysis method of this application;

[0055] Figure 3 This is a flowchart of an example of a method for analyzing code changes in this application;

[0056] Figure 4 This is a schematic diagram of the system structure of the code change analysis device according to the embodiment of the present application;

[0057] Figure 5 Schematic diagram of the device structure of the hardware operating environment involved in the code change analysis method in the embodiment of the present application.

[0058] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0059] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0060] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0061] Currently, the writing process of code change analysis reports mainly relies on manual operations. For example, analysts need to sort out the changes in the code one by one and manually enter the changed code. This is not only tedious and time-consuming, but also prone to errors, making the code change analysis inefficient. Manual analysis is also prone to missing the changed points in the code.

[0062] To this end, an embodiment of the present application proposes a code change analysis method, which obtains a baseline version relationship diagram, a change version relationship diagram and a source code library of the program to be analyzed, and first compares the baseline version relationship diagram with the change version relationship diagram to quickly determine the code change relationship and code change method of the program to be analyzed, and then obtains the differential source code of the code change method from the source code library, and then calls a preset large language model to determine the code change analysis summary of the program to be analyzed based on the differential source code and the code change relationship, thereby realizing automatic analysis of changes to the program to be analyzed.

[0063] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device that can realize the above functions.

[0064] Based on this, the embodiment of the present application provides a code change analysis method, referring to Figure 1 , Figure 1 This is a flow chart of an embodiment of the code change analysis method of the present application.

[0065] In this embodiment, the method includes steps S10 to S40:

[0066] Step S10, obtaining a baseline version relationship diagram, a changed version relationship diagram, and a source code library of the program to be analyzed;

[0067] It should be noted that the program to be analyzed refers to the program that needs to be compared with the previous and later versions, the baseline version relationship diagram refers to the representation of the baseline version of the program to be analyzed in the graph database, and the change version relationship diagram is the representation of the change version of the program to be analyzed in the graph database. The base version can be considered as the original version of the program to be analyzed, and the change version can be considered as the new version of the program to be analyzed. The source code library stores the baseline source code of the baseline version of the program to be analyzed, and also stores the change source code of the change version of the program to be analyzed.

[0068] Exemplarily, the baseline version and the modified version of the program to be analyzed may be stored in a graph database to obtain a baseline version relationship graph and a modified version relationship graph in the graph database.

[0069] In a feasible embodiment, step S10 further includes steps S11 to S14:

[0070] Step S11, obtaining a baseline version release package and a modified version release package of the program to be analyzed;

[0071] It should be noted that the embodiments of the present application can be applied to a change analysis system. The change analysis system can receive a version change analysis instruction. When receiving the version change analysis instruction, the baseline version release package and the change version release package of the program to be analyzed are obtained. The baseline version release package is the release package of the baseline version of the program to be analyzed, and the change version is the release package of the change version of the program to be analyzed. The baseline version release package and the change version release package can be stored in an artifact library of the change analysis system. The artifact library can store release packages corresponding to multiple versions of the program.

[0072] For example, the change analysis system also includes an interactive display interface, where the user can select the identifier of the baseline version release package and the identifier of the change version release package of the program to be analyzed to trigger the version change analysis instruction. When the change analysis system receives the version change analysis instruction, it obtains the baseline version release package and the change version release package from the artifact library. The change analysis system can also decompress the baseline version release package and the change version release package. Both the baseline version release package and the change version release package can be in binary form.

[0073] Step S12, calling the code parsing component to parse the baseline version release package and the modified version release package respectively, to obtain the first element relationship between each first code element of the baseline version release package and each first element relationship between each first code element, and to obtain the second element relationship between each second code element of the modified version release package and each second element relationship between each second code element;

[0074] It should be noted that the code parsing component can be Apache Commons BCEL (Byte Code Engineering Library, an open source Java class library). The code parsing component can be used to parse the decompressed baseline version release package and the modified version release package. The decompressed baseline version release package and the modified version release package can both be represented as Java class files. The first code element is characterized as an element constituting the baseline version release package, and the second code element is an element constituting the modified version release package. The first code element includes a first code package, a first class, a first interface, and a first method; the second code element includes a second code package, a second class, a second interface, and a second method. The code package is a Jar package. The first code package can include multiple first classes, and the first class can also include multiple first methods. Each first method can call each other through the first interface. The second code package can include multiple second classes, and the second class can also include multiple second methods. Each second method can call each other through the second interface. A class is a type defined in the code. Methods can be encapsulated together in a class. A method can be considered as a function defined in a class, which is used to perform specific operations or calculations. The interface can be an API (Application Programming Interface). The first interface can be obtained by parsing the annotations in the baseline version release package, and the second interface can be obtained by parsing the corresponding annotations in the change version release package. For example, the interface corresponding to the annotation @Post is HTTP API.

[0075] The first element relationship includes the inheritance relationship corresponding to the first class and the call relationship corresponding to each first interface. The second element relationship includes the inheritance relationship corresponding to the second class and the call relationship corresponding to each second interface. The inheritance relationship refers to a class (for example, a subclass) inheriting the properties and methods of another class (for example, a parent class). Through inheritance, the subclass can reuse the code of the parent class and can add or modify the behavior of the parent class. For example, there may be multiple first classes included in the baseline version release package. Among each first class, there is a first class that is a subclass and a first class that is a parent class. The inheritance relationship in the first element relationship is the inheritance relationship between each first class. There may be multiple second classes included in the change version release package. Among each second class, there is a second class that is a subclass and a second class that is a parent class. The inheritance relationship in the second element relationship is the inheritance relationship between each second class.

[0076] In other embodiments, the first code element may further include a configuration file of a baseline version release package, and the second code element may further include a configuration file of a changed version release package.

[0077] Step S13, determining the first hash value of each first code element in the baseline version release package, and determining the second hash value of each second code element in the changed version release package;

[0078] It should be noted that the hash value is an MD5 value (Message Digest Algorithm 5), each first code element has a corresponding first hash value, and each second code element has a corresponding second hash value. For example, the configuration file of the baseline version release package may also have a corresponding first hash value, and the content of the configuration file may be hashed to obtain the first hash value of the configuration file. For another example, the second hash value of the second method may be obtained by hashing the code content of the second method.

[0079] Step S14, constructing a baseline version relationship graph in the graph database according to the first element relationship, each first code element and each first hash value, and constructing a change version relationship graph according to the second element relationship, each second code element and each second hash value.

[0080] Each first code element and the corresponding first hash value can be used as the first node, and a baseline version relationship graph can be constructed in the graph database according to the first element relationship. The baseline version relationship graph can be used to describe the first element relationship between the first nodes; each second code element and the corresponding second hash value can be used as the second node, and a change version relationship graph can be constructed in the graph database according to the second element relationship. The change version relationship graph can be used to describe the second element relationship between the second nodes. The first node can be considered as the first code element carrying the first hash value, and the second node can be considered as the second code element carrying the second hash value. The first hash value of the configuration file in the baseline version release package can be used as the first node and exist alone in the baseline version relationship graph, and the second hash value of the configuration file in the change version release package can be used as the second node and exist alone in the change version relationship graph.

[0081] This embodiment obtains the baseline version release package and the modified version release package to determine the corresponding baseline version relationship diagram and modified version relationship diagram, thereby facilitating the improvement of the comprehensiveness of the change analysis. It is convenient to compare the changes caused by the change of the compilation environment but the source code remains unchanged, or the code changes automatically generated by the source code template, which cannot be found by directly comparing the baseline source code and the modified source code of the program to be analyzed.

[0082] Step S20, comparing the baseline version relationship diagram and the changed version relationship diagram to obtain version change data, where the version change data includes at least one of a code change relationship and a code change method;

[0083] It should be noted that the version change data may include at least one of a code change relationship and a code change method. The code change relationship is characterized by a change in the relationship in the program to be analyzed. For example, if the second element relationship is different from the first element relationship, it can be considered that the relationship in the program to be analyzed has changed. In this case, the version change data includes the code change relationship. The code change method is characterized by a change in the changed version of the program to be analyzed relative to the method in the baseline version. For example, if the second hash value in the changed version of the same method signature is different from the first hash value in the baseline version, it is considered that the method corresponding to the program to be analyzed has changed. In this case, the code change data includes the code change method. The method signature can be used to describe the path of the method. For example, each of the first method and the second method has its own corresponding method signature. If the method signatures of the first method and the second method are the same, it is considered that the paths of the first method and the second method are the same. For the first method and the second method with the same method signature, if the second method changes, it can be considered that the first method and the second method with the same method signature are the same and can achieve the same function.

[0084] Exemplarily, the baseline version relationship graph and the changed version relationship graph may be traversed to obtain the version change data.

[0085] In a feasible embodiment, step S20 further includes: steps S21 to S22:

[0086] Step S21, comparing the baseline version relationship graph and the changed version relationship graph according to each first hash value in the baseline version relationship graph and each second hash value in the changed version relationship graph, to obtain a code change method;

[0087] It should be noted that the baseline version relationship graph and the changed version relationship graph can be compared by comparing the first hash value and the second hash value.

[0088] For example, you can first compare the first hash value of the first code package and the second hash value of the second code package in the baseline version relationship diagram and the change version relationship diagram. Each first code package and second code package has its own corresponding package signature, and the package signature can be determined based on the path of the code package. If the first hash value and the second hash value of the same package signature are the same, it means that the first code package and the second code package of the package signature are the same, then the second categories and second methods included in the second code package are also the same as the first categories and second methods in the first code package, and there is no need to compare the second categories and second methods included in the second code package of the package signature, thereby improving the efficiency of change analysis. If the first hash value of each first code package in the baseline version relationship diagram is the same as the second hash value of each second code package in the change version relationship diagram, it is determined that there is no method change in the program to be analyzed, and there is no code change method in the version change relationship.

[0089] Since a code package may include multiple classes in the code, and a class may include multiple methods, when comparing based on the first hash value and the second hash value, the first code package and the second code package may be compared first. When the first hash value and the second hash value of the signature of the same package are different, the first hash value and the second hash value of the signature of the same class in the first code package and the second code package are compared. When the first hash value and the second hash value of the signature of the same class are different, the first hash value and the second hash value of the first method and the second hash value of the same method signature in the first class and the second class are compared. Each of the first class and the second class has a corresponding class signature. The class signature of the first class can be determined based on the path of the first class, and the class signature of the second class can be determined based on the path of the second class. Thus, the efficiency of change analysis can be improved. When the first hash value and the second hash value of the signature of the same package are the same, the hash values ​​corresponding to the classes and methods of the next level corresponding to the signature of the package will not be compared, and / or when the first hash value and the second hash value of the signature of the same class are the same, the methods of the next level corresponding to the signature of the class will not be compared, thereby facilitating the improvement of the efficiency of code change analysis.

[0090] In a feasible embodiment, step S21 further includes steps S211 to S215:

[0091] Step S211, comparing the baseline version relationship graph and the changed version relationship graph, if the baseline version relationship graph contains the target deletion first Hash value deleted in the changed version relationship graph, determining that the code change method includes the target deletion first method of deleting the target first Hash value;

[0092] It should be noted that changes include modification, deletion and addition, so in this embodiment, the baseline version relationship graph and the change version relationship graph can be traversed to determine whether there are new methods, modified methods and deleted methods in the change version relationship graph. When there is a modified, deleted or added second method in the change version relationship graph, the second hash value of the second class where the second method is located is different from the first hash value of the corresponding first class, and the second hash value of the second code package where the second method is located is different from the first hash value of the corresponding first code package. Therefore, the modified, deleted or added second method in the change version relationship graph can still be found by comparing the hash value of the code package, the hash value of the class and the hash value of the method in turn.

[0093] Exemplarily, in the case where the first hash value and the second hash value corresponding to the same type of signature are different in the baseline version relationship diagram and the changed version relationship diagram, if the number of first hash values ​​included in the first type of the signature is greater than the number of second hash values ​​included in the second type, it can be determined that there is a target deletion first hash value to be deleted in the changed version relationship diagram. Among them, the step of determining the target deletion first method of the target deletion first hash value may include: for the first type and the second type of signature with the same type and different first hash values ​​and second hash values, the target method signature that does not exist in the second type can be found in the method signatures of each first method in the first type, the target method signature corresponding to the first hash value in the first type is the target deletion first hash value, and the first method corresponding to the target method signature is the target deletion first method.

[0094] Step S212, if there is a target change second hash value different from each first hash value in the baseline version relationship graph in the change version relationship graph, then determine whether there is a method signature of the target change second hash value in the baseline version relationship graph;

[0095] It should be noted that the method signature of the target change second hash value is the method signature of the second method corresponding to the target change second hash value. Exemplarily, if there is a first code package with the same package signature but a first hash value that is different from the second hash value of the second code package, then the first target category and the second target category that belong to the same type of signature but have different first hash values ​​are determined from the first code package and the second code package; among the second hash values ​​of each second method included in the target category, the target change second hash value that is different from each first hash value of the target category is determined; and it is determined whether there is a method signature corresponding to the target change second hash value in the target category of the baseline version relationship diagram.

[0096] Step S213, if the method signature of the target change second hash value does not exist in the baseline version relationship graph, determining that the code change method includes the target change second method of the target change second hash value;

[0097] It should be noted that if the target change second hash value does not exist in the baseline version relationship graph, it means that the target change second method of the target change second hash value is a newly added method. Continuing with the previous example, it is determined whether there is a method signature corresponding to the target change second hash value in the target first class of the baseline version relationship graph; if the method signature corresponding to the target change second hash value does not exist in the target first class, it is determined that the code change method includes the target change second method of the target change second hash value.

[0098] Step S214, if there is a method signature of the target change second hash value in the baseline version relationship graph, determine the target change first method that is identical to the method signature in the baseline version relationship graph, and obtain the first bytecode of the target change first method and the second bytecode of the target change second method;

[0099] Step S215, when there is a functional difference between the first bytecode and the second bytecode, determining that the code change method includes a first target change method and a second target change method, and the functional difference is characterized by a difference between a first parameter called by the first bytecode and a second parameter called by the second bytecode.

[0100] It should be noted that if there is a method signature of the target change second hash value in the baseline version relationship graph, it means that the target change second method of the target change second hash value is a modified method, and the target change first method with the same method signature as the target change second hash value can be found in the baseline version relationship graph.

[0101] The first bytecode of the first target change method and the second bytecode of the second target change method can be further obtained to accurately determine whether there is a functional change in the second target change method. When the second bytecode corresponding to the second target change method changes, the second hash value of the second target change method will also change, but the second bytecode corresponding to the second target change method may only change in form, but the function implemented by the second bytecode may be consistent with the function implemented by the first bytecode. In this embodiment, when the functions implemented by the first bytecode and the second bytecode are consistent, the second target change method corresponding to the second bytecode is not considered to have changed. At this time, the code change method does not include the second target change method corresponding to the second bytecode and the first target change method corresponding to the first bytecode, thereby improving the accuracy of change analysis.

[0102] The first bytecode may be a representation of the first target change method in the baseline version release package, and the first bytecode includes instructions required to implement the first target change method. The second bytecode may be a representation of the second target change method in the change version release package, and the second bytecode includes instructions required to implement the second target change method.

[0103] The functional difference is characterized by a difference between a first parameter of the first bytecode call and a second parameter of the second bytecode call. The first parameter of the first bytecode call is a parameter that the instruction in the first bytecode indicates to load, for example, it may be a parameter that the instruction indicates needs to be obtained. The second parameter of the second bytecode call is a parameter that the instruction in the second bytecode indicates to load, and may also be a parameter that the instruction indicates needs to be obtained.

[0104] Exemplarily, if there is a method signature of the target change second hash value in the baseline version relationship graph, then the target change first method identical to the method signature is determined in the baseline version relationship graph, and the first bytecode of the target change first method is obtained from the baseline version release package, and the second bytecode of the target change second method is obtained from the change version release package; when the first parameter of the first bytecode call and the second parameter of the second bytecode call are the same, it is determined that the target change second method corresponding to the second bytecode has not changed, and the code change method does not include the target change second method corresponding to the second bytecode. When the first parameter of the first bytecode call and the second parameter of the second bytecode call are different, it is determined that the target change second method corresponding to the second bytecode has changed, and it is determined that the code change method includes the target change first method and the target change second method.

[0105] Therefore, the modified target change second method can be accurately determined, and the target change second method whose function is not modified is avoided from being used as the code change method, thereby improving the accuracy of code change analysis.

[0106] Step S22, based on the first element relationship in the baseline version relationship graph and the second element relationship in the change version relationship graph, the baseline version relationship graph and the change version relationship graph are compared to obtain a code change relationship.

[0107] It should be noted that the first element relationship includes the call relationship, and the second element relationship includes the call relationship. When the call relationship of the first element relationship and the call relationship of the second element relationship are different, it can be considered that the relationship of the program to be analyzed has changed. For example, the difference between the call relationship in the first element relationship and the call relationship in the second element relationship can be compared to compare the difference between the baseline version relationship diagram and the changed version relationship diagram, and then determine the code change relationship.

[0108] This embodiment determines the code change method by comparing the first Hash value and the second Hash value, and determines the code change relationship by comparing the first element relationship and the second element relationship, thereby improving the accuracy of code change analysis.

[0109] In a feasible embodiment, step S22 includes steps S221 to S223:

[0110] Step S221, comparing the first element relationship and the second element relationship, and determining in the second element relationship an interface call change relationship that is different from the first element relationship;

[0111] Step S222, determining the call changed interface from the interface call change relationship, determining the interface call chain of the call changed interface in the second element relationship, and using the interface call chain as the code change relationship.

[0112] It should be noted that the interface call change relationship is the call relationship in which the second element relationship has been changed, and the call change interface is the second interface in which the call relationship has been changed. Compared with the baseline source code, the call relationship between the second interfaces in the changed source code may change, so in this embodiment, by comparing the first element relationship and the second element relationship, the interface call change relationship that is different from the first element relationship is determined in the second element relationship.

[0113] The interface call chain refers to the set of second interfaces that are called in succession to the call change interface. For example, the first interfaces in the first element relationship are A, B, C and D, and the second interfaces A, B, C and D also exist in the second element relationship. The call relationship in the first element relationship is A calls B calls C, and D has not been called by any of ABC. However, in the second element relationship, A calls B, but B calls D, and B does not call C. Therefore, in the second element relationship, B calls D, which is an interface call change relationship, B is a call change interface, and A calls B calls D, which is an interface call chain.

[0114] Exemplarily, the calling relationship in the first element relationship is compared with the calling relationship in the second element relationship, and the interface calling relationship that is different from the first element relationship is determined in the calling relationship of the second element relationship, and the calling change interface is determined in the interface calling relationship, that is, the next interface called by the calling change interface in the second element relationship is different from the next interface called in the first element relationship; in the second element relationship, the associated interface that has an indirect calling relationship and / or a direct calling relationship with the calling change interface is searched, and the interface calling chain is determined according to the calling relationship between the calling change interface and each associated interface, and the interface calling chain is used as the code change relationship. The direct calling relationship includes: the relationship between the calling change interface and the next interface called by the calling change interface, and the relationship between the calling change interface and the interface that calls the calling change interface. For example, A calls B and calls C, and both A and C have a direct calling relationship with B. For another example, E calls A, B, C, and D. If B is a calling change interface, the interfaces that have an indirect calling relationship with B are E and D, and the interfaces that have a direct calling relationship with B are A and C. E calling A, B, C, and D can be considered as an interface calling chain.

[0115] This embodiment determines the interface call change relationship in the second element relationship that is different from the first element relationship through the first element relationship, thereby achieving more comprehensive change analysis.

[0116] Step S30, obtaining the difference source code of the code change method from the source code library;

[0117] It should be noted that the code changing method may include a first target changing method and / or a first target deleting method, and the code changing method may also include a first target changing method and a second target changing method.

[0118] The difference source code may include at least one sub-source code. For example, the sub-source code included in the difference source code may be the first difference source code, the second difference source code, or the first deletion source code. The difference source code may include the first difference source code and the second difference source code at the same time, or may include the first difference source code, the second difference source code, and the first deletion source code at the same time, or may only include the first deletion source code. The source code library includes the baseline source code and the changed source code.

[0119] For example, the first difference source code of the target first change method can be obtained in the baseline source code, the first deletion source code of the target first deletion method can be obtained in the baseline source code, and the second difference source code of the target second change method can be obtained in the change source code.

[0120] In a feasible embodiment, step S30 further includes steps S31 to S33:

[0121] Step S31, when the code change method includes a target deletion first method, obtaining a first deletion source code of the target deletion first method in the baseline source code of the source code library according to the first start and end lines of the target deletion first method;

[0122] Step S32, when the code change method includes the first target change method, obtaining the first difference source code of the first target change method in the baseline source code of the source code library according to the second start and end lines of the first target change method;

[0123] Step S33, when the code change method includes the target change second method, according to the third start and end lines of the target change second method, obtain the second difference source code of the target change second method in the change source code of the source code library.

[0124] It should be noted that the first start and end lines represent the first starting line number and the first ending line number of the code corresponding to the target deletion method in the baseline source code, the second start and end lines represent the second starting line number and the second ending line number of the code corresponding to the target change method in the baseline source code, and the third start and end lines represent the third starting line number and the third ending line number of the code corresponding to the target change method in the changed source code.

[0125] Exemplarily, when the code change method includes a target deletion first method, the code between the first start and end line numbers and the first end line number of the baseline source code is used as the first deletion source code of the target deletion first method; when the code change method includes a target change first method, the code between the second start and end line numbers and the second end line number of the baseline source code is used as the first difference source code of the target change first method; when the code change method includes a target change second method, the code between the third start line and the third end line in the change source code is used as the second difference source code of the target change second method.

[0126] This embodiment obtains the first deletion source code of the first method of target deletion, the first difference source code of the first method of target change, and / or the second difference source code of the second method of target change, so as to facilitate the subsequent source code-based analysis of the specific code change situation in the program to be analyzed, thereby improving the accuracy of the change analysis. Instead of directly comparing the baseline source code and the changed source code, the code change method is first quickly determined through the baseline version relationship diagram and the changed version relationship diagram, and then the difference source code corresponding to the code change method is determined, such as the first difference source code, the second difference source code and / or the first deletion source code, and then the change analysis is performed on the first difference source code, the second difference source code and / or the first deletion source code, so as to avoid directly comparing the baseline source code and the changed source code one by one, thereby improving the change analysis efficiency of the program to be analyzed.

[0127] Step S40, calling a preset large language model, and determining a code change analysis summary of the program to be analyzed according to the difference source code and the code change relationship.

[0128] It should be noted that the preset large language model may be an LLM model (Large Language Model), and the code change analysis summary includes a method business change summary and a relationship business change summary. The method business change summary is used to describe the business processing logic corresponding to the change of the difference source code, and the relationship business change summary is used to describe the business processing logic corresponding to the change of the code change relationship. Business processing logic refers to the business rules executed by the code, etc.

[0129] Exemplarily, a method business change summary may be determined based on the difference source code and a preset large language model, and a relationship business change summary may be determined based on the code change relationship and a preset large language model.

[0130] Since the embodiment of the present application can compare the baseline version relationship diagram and the changed version relationship diagram of the code to be analyzed to obtain the version difference data of the code to be analyzed, the code change relationship and the code change method in the code to be analyzed can be automatically determined by comparing the baseline version relationship diagram and the changed version relationship diagram, and then the difference source code of the code change method in the version difference data is obtained from the source code library, and the preset large language model is called to determine the code change analysis summary of the program to be analyzed according to the difference source code and the code change relationship, thereby realizing automatic analysis of the changes of the program to be analyzed without manual analysis, thereby improving the change analysis efficiency of the code to be analyzed.

[0131] For a better understanding of this embodiment, refer to Figure 2 , briefly describe the change analysis system, graph database, source code library, etc. in this embodiment. The change analysis system includes an interactive display interface. The user can select the identifier of the baseline version release package and the identifier of the change version release package of the program to be analyzed in the interactive display interface to trigger the version change analysis instruction. When the change analysis system receives the version change analysis instruction, the change analysis system can obtain the baseline version release package and the change version release package from the product library. The change analysis system can also decompress the baseline version release package and the change version release package. The change analysis system can store the baseline version relationship diagram of the baseline version release package in the graph database, and can also store the change version relationship diagram of the change version release package in the graph database. The change analysis system can obtain the difference source code from the source code library. The change analysis system can call the preset large language model to perform code change analysis on the program to be analyzed. For example, the preset large language model is called to determine the code change analysis summary of the program to be analyzed based on the difference source code and the code change relationship. The source code library can be a Git repository (an open source distributed version control system, Git-Thestupid content tracker).

[0132] In a feasible embodiment, step S40 further includes steps S41 to S44:

[0133] Step S41, generating a business change analysis prompt statement according to a preset business change analysis prompt template, a difference source code, and a class name corresponding to the difference source code;

[0134] Step S42, inputting the business change analysis prompt statement into the preset large language model, obtaining the code change content output by the preset large language model and the method business change summary of the code change content;

[0135] It should be noted that the business change analysis prompt statement can be used to prompt the preset large language model to analyze the input source code; the method business change summary is used to briefly describe the code change content, and the code change content can record the change details corresponding to the difference source code. The preset business change analysis prompt template is a template for prompting the preset large language model to perform code content analysis.

[0136] The second difference source code can be divided into a new type and a modified type, that is, the second new source code of the new type and the second modified source code of the modified type both belong to the second difference source code. The type of the second difference source code can be determined based on the type of the second target change method, and the type of the second target change method is the same as the type of the second difference source code.

[0137] Exemplarily, if there is a target change second hash value in the change version relationship graph that is different from the first hash values ​​in the baseline version relationship graph, and there is no method signature for the target change second hash value in the baseline version relationship graph, then the target change second method is a newly added type, and the second difference source code obtained from the change source code is the second newly added source code.

[0138] If there is a target change second hash value in the change version relationship graph that is different from each first hash value in the baseline version relationship graph, and there is a method signature of the target change second hash value in the baseline version relationship graph, then the target change second method is a modification type, and the second difference source code obtained from the change source code is the second modified source code. The original source code corresponding to the second modified source code in the baseline source code is the first difference source code, and the second newly added source code does not have a corresponding original source code in the baseline source code, that is, the second newly added source code does not have a corresponding first difference source code.

[0139] The first deleted source code may have a corresponding business change analysis prompt statement, the second added source code may have a corresponding business change analysis prompt statement, and the first difference source code and the second modified source code may together correspond to one business change analysis prompt statement.

[0140] Exemplarily, when the difference source code includes the first deleted source code, the first deleted source code is substituted into the preset first position of the preset business change analysis template, and the class name of the class where the first deleted source code is located is obtained, and the class name of the first deleted source code is substituted into the preset second position of the preset business change analysis model to obtain the business change analysis prompt statement of the first deleted source code. The business change analysis prompt statement of the first deleted source code is input into the preset large language model so that the preset large language model can parse the business logic of the first deleted source code, output the code change content of the first deleted source code, and the method business change summary, wherein the code change content of the first deleted source code may include the first deleted source code and the business processing logic implemented by the first deleted source code, and the business processing logic in the code change content is described in natural language, so that relevant users can easily understand the changes in the code to be analyzed. In this case, the method business change summary is also the business processing logic of the first deleted source code described in natural language.

[0141] Exemplarily, when the difference source code includes the second newly added source code, the second newly added source code is substituted into the preset first position of the preset business change analysis template, and the class name of the class where the second newly added source code is located is obtained, and the class name of the second newly added source code is substituted into the preset second position of the preset business change analysis model to obtain the business change analysis prompt statement of the second newly added source code. The business change analysis prompt statement of the second newly added source code is input into the preset large language model so that the preset large language model can parse the business logic of the second newly added source code, output the code change content of the second newly added source code, and the method business change summary, wherein the code change content of the second newly added source code may include the second newly added source code and the business processing logic implemented by the second newly added source code, and the business processing logic in the code change content is described in natural language, so that relevant users can easily understand the changes in the code to be analyzed. In this case, the method business change summary is also the business processing logic of the second newly added source code described in natural language. For example, the preset business change analysis prompt template can be: Please compare the differences between the first difference source code and the second modified source code, and please describe the business logic changes caused by the second modified source code. The description needs to be objective and does not contain any opinions or suggestions: [Fill in the first difference source code; fill in the class where the first difference source code is located], [Fill in the second modified source code; fill in the class where the second modified source code is located]. The preset business change analysis prompt template can be adjusted based on actual conditions, and this embodiment does not make specific restrictions on this.

[0142] In this embodiment, when the second newly added source code is input into the preset large language model, the class name of the class to which it belongs is also input into the preset large language model, so that the preset large language can understand the upper and lower codes of the second newly added source code based on the class name of the second newly added source code, so as to more accurately output the second newly added code change content. When the first newly added source code is input into the preset large language model, the class name of the class to which it belongs is also input into the preset large language model, so as to more accurately output the first deleted source code code change content.

[0143] Exemplarily, when the difference source code includes the second modified source code and the first difference source code, the first difference source code and the second modified source code are respectively substituted into the preset first position of the preset business change analysis template, the first difference source code is sorted before the second modified source code at the preset first position, and the class name of the class where the second modified source code is located and the class name of the class where the first difference source code is located are obtained, the class name of the second modified source code and the type of the first difference source code are substituted into the preset second position of the preset business change analysis model, and the business change analysis prompt statements of the first difference source code and the second modified source code are obtained. The business change analysis prompt statement of the first difference source code and the second modified source code is input into the preset large language model, so that the preset large language model compares the first difference source code and the second modified source code, analyzes the business logic of the second modified source code change, and outputs the code change content corresponding to the first difference source code and the second modified source code, as well as the method business change summary, wherein the code change content corresponding to the first difference source code and the second modified source code may include the difference between the first difference source code and the second modified source code, and the difference between the business processing logics implemented by the first difference source code and the second modified source code respectively. The difference between the business processing logics can be described in natural language, so as to facilitate relevant users to easily understand the changes in the code to be analyzed. In this case, the method business change summary also describes the difference between the business processing logic between the first difference source code and the second modified source code in natural language.

[0144] Step S43, generating an interface change analysis prompt statement according to a preset interface change analysis prompt template and a code change relationship;

[0145] Step S44, inputting the interface change analysis prompt statement into the preset large language model to obtain the interface change summary of the code change relationship.

[0146] It should be noted that the preset interface change analysis prompt template is a template used to prompt the preset large language model to perform call relationship change analysis. The interface change analysis prompt statement is used to prompt the preset large language model to analyze the business logic change of the input code change relationship. The interface change summary is a natural language description of the business logic changes caused by the call relationship changes.

[0147] Exemplarily, the code change relationship can be filled into the preset prompt position of the preset interface change analysis prompt template to generate an interface change analysis prompt statement, and the interface change analysis prompt statement can be input into the preset large language model so that the preset large language model can analyze the business logic changes of the code change relationship and output the interface change summary of the code change relationship.

[0148] This embodiment analyzes the difference source code and the code change relationship through a preset large language model, thereby outputting a method business change summary and an interface change summary described in natural language, which is easy for relevant users to understand.

[0149] In a feasible embodiment, after step S44, steps S441 to S442 are further included:

[0150] Step S441, obtaining code change requirement information of the program to be analyzed, and calling a preset large language model to generate a requirement summary of the code change requirement information;

[0151] Step S442: The requirement summary, the code change analysis summary, the code business change content, and the code change relationship of the program to be analyzed are used as a code change analysis report of the program to be analyzed.

[0152] It should be noted that the code change requirement information is used to describe the functions that are expected to be implemented in the changed source code but are not implemented in the baseline source code. The code change requirement information can be considered as the functions that need to be implemented by the changed source code. The requirement summary is used to briefly describe the code change requirement information. The requirement summary can be composed of several keywords in the code change requirement information. Exemplarily, the code change requirement information can be input into a preset large language model, and the preset large language model can extract the requirement summary from the code change requirement information.

[0153] The code change analysis report can reflect the changes corresponding to the program to be analyzed as a whole. The code change analysis report can include a requirement summary, a code change analysis summary, code business change content, and a code change relationship. In other embodiments, the code change analysis report can also include an overall change summary, a file change list, etc. All code change analysis summaries corresponding to the program to be analyzed can be input into a preset large language model, and the preset large language model summarizes all code change analysis summaries to obtain an overall change summary. The file change list includes the changed configuration files corresponding to the program to be analyzed. For example, if the configuration file of the changed version is changed relative to the configuration file of the baseline version, the file change list includes the configuration file in the changed version. The first hash value and the second hash value of the configuration file of the changed version and the configuration file of the baseline version with the same configuration file name can be compared. When the first hash value and the second hash value are different, it is determined that there is a configuration file in the changed version that has changed relative to the baseline version.

[0154] This embodiment comprehensively reflects the changes corresponding to the program to be analyzed through the code change analysis report, thereby facilitating a comprehensive understanding of the changes in the program to be analyzed, and there is a requirement summary in the code change analysis report, so based on the requirement summary, it is determined whether the changes generated by the changed version of the program to be analyzed comply with the requirement summary, thereby facilitating subsequent processing by relevant users.

[0155] For a better understanding of this embodiment, please refer to Figure 3 , the overall process of this embodiment is briefly described: a baseline version release package and a change version release package are obtained from the product library, the baseline version release package and the change version release package are parsed respectively, a baseline version relationship diagram and a change version relationship diagram are constructed in the graph database, the baseline version relationship diagram and the change version relationship diagram are compared to obtain version difference data, based on the code change method in the version difference data, the difference source code is obtained from the source code library, the user large language model is called, the difference source code and the code change relationship in the version difference data are analyzed to obtain a code change analysis summary, and the obtained code requirement change information is also input into the preset large language model, the preset large language model can determine the requirement summary from the code requirement change information, and the preset large language model can summarize all the code change analysis summaries corresponding to the program to be analyzed as a whole to obtain an overall change summary, and can also obtain a change file list by comparing the baseline version relationship diagram and the change version relationship diagram, and the requirement summary, the overall change summary, the code change analysis summary, the change file list, the code business change content and the code change relationship of the program to be analyzed can be used as a code change analysis report of the program to be analyzed.

[0156] This application also provides a code change analysis device, please refer to Figure 4 , the code change analysis device comprises:

[0157] A first acquisition module 10 is used to acquire a baseline version relationship diagram, a changed version relationship diagram, and a source code library of the program to be analyzed;

[0158] A comparison module 20, configured to compare the baseline version relationship diagram and the changed version relationship diagram to obtain version change data, wherein the version change data includes at least one of a code change relationship and a code change method;

[0159] The second acquisition module 30 is used to acquire the difference source code of the code change method from the source code library;

[0160] The calling module 40 is used to call the preset large language model and determine the code change analysis summary of the program to be analyzed according to the difference source code and the code change relationship.

[0161] The code change analysis device provided by the present application adopts the code change analysis method in the above-mentioned embodiment, aiming to solve the technical problem of low efficiency of code change analysis. Compared with the prior art, the beneficial effects of the code change analysis method provided in the embodiment of the present application are the same as the beneficial effects of the code change analysis method provided in the above-mentioned embodiment, and other technical features in the code change analysis device are the same as the features disclosed in the above-mentioned embodiment method, which will not be repeated here. The embodiment of the present application provides an electronic device, which can be a playback device, and the electronic device includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that at least one processor can execute the code change analysis method in the above-mentioned embodiment.

[0162] Reference below Figure 5 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. The electronic device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0163] like Figure 5 As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM) 1004. In RAM 1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM 1002, and RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems may be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device may allow the electronic device to communicate wirelessly or wired with other devices to exchange data. Although the electronic device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have instead.

[0164] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 1009, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0165] The electronic device provided by the present application adopts the code change analysis method in the above embodiment 1 to solve the technical problem of low efficiency of code change analysis. Compared with the prior art, the beneficial effect of product flow data distribution provided by the embodiment of the present application is the same as the beneficial effect of the code change analysis method provided by the above embodiment, and the other technical features in the code change analysis device are the same as the features disclosed by the above embodiment method, which will not be repeated here. It should be understood that the various parts of the present disclosure can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in a suitable manner in any one or more embodiments or examples. The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims. The present embodiment provides a computer-readable storage medium having computer-readable program instructions stored thereon, and the computer-readable program instructions are used to execute the code change analysis method in the above embodiment 1. The computer-readable storage medium provided in the embodiment of the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor devices, equipment or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable EPROM (Electrical Programmable Read Only Memory) or flash memory, an optical fiber, a portable compact disk CD-ROM (compact disc read-only memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution device, device or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency, radio frequency), etc., or any suitable combination of the above. The above-mentioned computer-readable storage medium may be contained in an electronic device; it may also exist alone without being assembled into an electronic device.The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device: obtains a baseline version relationship diagram, a change version relationship diagram and a source code library of the program to be analyzed; compares the baseline version relationship diagram and the change version relationship diagram to obtain version change data, wherein the version change data includes at least one of a code change relationship and a code change method; obtains a differential source code of the code change method from the source code library; and calls a preset large language model to determine a code change analysis summary of the program to be analyzed based on the differential source code and the code change relationship.

[0166] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a LAN (local area network) or WAN (Wide Area Network), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0167] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based device that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0168] The modules involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The name of the module does not constitute a limitation on the unit itself under certain circumstances. The computer-readable storage medium provided in the present application stores computer-readable program instructions for executing the above-mentioned code change analysis method, aiming to solve the technical problem of low efficiency of code change analysis. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the embodiments of the present application are the same as the beneficial effects of the code change analysis method provided in the above-mentioned embodiments, which will not be repeated here.

[0169] The present application also provides a computer program product, including a computer program, which implements the steps of the code change analysis method as described above when the computer program is executed by a processor. The computer program product provided by the present application is intended to solve the technical problem of low efficiency of code change analysis. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of the present application are the same as the beneficial effects of the code change analysis method provided by the above embodiment, which will not be repeated here. The above is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. All equivalent structures or equivalent process transformations made using the contents of the specification and drawings of this application, or directly or indirectly used in other related technical fields, are similarly included in the patent processing scope of the present application.

Claims

1. A code change analysis method, characterized in that: The method includes: Obtain the baseline version relationship diagram, changed version relationship diagram and source code library of the program to be analyzed; Comparing the baseline version relationship diagram with the changed version relationship diagram to obtain version change data, wherein the version change data includes at least one of a code change relationship and a code change method; Obtaining the differential source code of the code change method from the source code library; A preset large language model is called to determine a code change analysis summary of the program to be analyzed according to the difference source code and the code change relationship.

2. The method according to claim 1, characterized in that The steps of obtaining the baseline version relationship diagram and the changed version relationship diagram of the program to be analyzed include: Obtain the baseline version release package and the changed version release package of the program to be analyzed; Calling the code parsing component to parse the baseline version release package and the modified version release package respectively, obtaining the first element relationship between each first code element of the baseline version release package and each first code element, and obtaining the second element relationship between each second code element of the modified version release package and each second code element; Determine a first hash value for each of the first code elements in the baseline version release package, and determine a second hash value for each of the second code elements in the changed version release package; A baseline version relationship graph is constructed in a graph database according to the first element relationship, each of the first code elements and their respective first hash values, and a change version relationship graph is constructed according to the second element relationship, each of the second code elements and their respective second hash values.

3. The method according to claim 2, characterized in that The step of comparing the baseline version relationship diagram with the changed version relationship diagram to obtain version change data comprises: According to each first hash value in the baseline version relationship graph and each second hash value in the change version relationship graph, the baseline version relationship graph and the change version relationship graph are compared to obtain a code change method; According to the first element relationship in the baseline version relationship graph and the second element relationship in the change version relationship graph, the baseline version relationship graph and the change version relationship graph are compared to obtain a code change relationship.

4. The method according to claim 3, characterized in that The first code element includes a first method, and the second code element includes a second method; The step of comparing the baseline version relationship graph and the changed version relationship graph according to each first hash value in the baseline version relationship graph and each second hash value in the changed version relationship graph to obtain the code change method comprises: Comparing the baseline version relationship graph with the changed version relationship graph, if the baseline version relationship graph contains a target deletion first Hash value deleted in the changed version relationship graph, determining that the code change method includes a target deletion first method of deleting the target deletion first Hash value; If there is a target change second hash value in the change version relationship graph that is different from each of the first hash values ​​in the baseline version relationship graph, determining whether there is a method signature for the target change second hash value in the baseline version relationship graph; If the method signature of the target change second hash value does not exist in the baseline version relationship graph, determining that the code change method includes the target change second method of the target change second hash value; If a method signature of the target change second hash value exists in the baseline version relationship graph, a target change first method identical to the method signature is determined in the baseline version relationship graph, and a first bytecode of the target change first method and a second bytecode of the target change second method are obtained; In the case that there is a functional difference between the first bytecode and the second bytecode, determining that the code change method includes the target change first method and the target change second method, the functional difference is characterized by a difference between a first parameter called by the first bytecode and a second parameter called by the second bytecode.

5. The method according to claim 3, characterized in that The step of comparing the baseline version relationship graph and the changed version relationship graph according to the first element relationship in the baseline version relationship graph and the second element relationship in the changed version relationship graph to obtain the code change relationship comprises: comparing the first element relationship and the second element relationship, and determining, in the second element relationship, an interface call change relationship that is different from the first element relationship; A call change interface is determined from the interface call change relationship, an interface call chain of the call change interface is determined in the second element relationship, and the interface call chain is used as a code change relationship.

6. The method according to claim 1, characterized in that The difference source code includes at least one sub-source code, and the sub-source code is the first difference source code, the second difference source code or the first deletion source code; The step of obtaining the difference source code of the code change method from the source code library includes: In a case where the code change method includes a target deletion first method, obtaining a first deletion source code of the target deletion first method in the baseline source code of the source code library according to the first start and end lines of the target deletion first method; In a case where the code change method includes a first target change method, obtaining a first difference source code of the first target change method in the baseline source code of the source code library according to the second start and end lines of the first target change method; In the case where the code change method includes a second target change method, a second difference source code of the second target change method is obtained from the changed source code of the source code library according to the third start and end lines of the second target change method.

7. The method according to claim 1, characterized in that The code change analysis summary includes a method business change summary and a relationship business change summary; The step of calling the preset large language model to generate a code change analysis summary of the difference source code and the code change relationship includes: Generate a business change analysis prompt statement according to a preset business change analysis prompt template, the difference source code, and the class name corresponding to the difference source code; Input the business change analysis prompt statement into a preset large language model to obtain the code change content output by the preset large language model and the method business change summary of the code change content; Generate an interface change analysis prompt statement according to a preset interface change analysis prompt template and the code change relationship; The interface change analysis prompt statement is input into a preset large language model to obtain an interface change summary of the code change relationship.

8. The method according to claim 7, characterized in that After the step of inputting the interface change analysis prompt statement into a preset large language model to obtain the interface change summary of the code change relationship, the step further includes: Obtain code change requirement information of the program to be analyzed, and call a preset large language model to generate a requirement summary of the code change requirement information; The requirement summary, code change analysis summary, code business change content, and code change relationship of the program to be analyzed are used as a code change analysis report of the program to be analyzed.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the code change analysis method described in any one of claims 1 to 8.

10. A readable storage medium, characterized in that: The readable storage medium is a computer-readable storage medium, on which is stored a program for implementing the code change analysis method, and the program for implementing the code change analysis method is executed by a processor to implement the steps of the code change analysis method as described in any one of claims 1 to 8.

Citation Information

Cited By

  • Regression test case determination method, electronic equipment and medium

    CN122045065A

  • Method and system for generative ai-based graphical comparison of engineering objects

    WO2026167056A1