Code merging method and device, equipment and medium
By detecting and repairing the merged code and combining the code to detect the repair information of the big model, the problem of manual adjustment of code is solved, and the efficiency and security of code merging is achieved.
Patent Information
- Application Number
- CN202411915626.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, manual adjustment of the code to be merged has low accuracy and low efficiency, which may cause the backbone code to crash after merging.
By obtaining the backbone code and the code to be merged, detecting it to obtain code failure information, generating fault prompt information and sending it to the code detection model, obtaining code repair information, and repairing the merged code based on the repair information and then merging it into the backbone code.
It improves the accuracy of code merging, ensures that the code to be merged can run safely after it is merged into the backbone code, and improves the efficiency and accuracy of code merging.
Smart Images

Figure CN119759742A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a code merging method, device, equipment and medium. Background Art
[0002] With the rapid development of science and technology, software programs are constantly upgraded to obtain more software functions. The code to be merged with new functions can be merged into the original trunk code to give the original software program new functions. However, if there is a fault in the code to be merged, the trunk code will crash after the merger, so the code to be merged needs to be tested before merging.
[0003] Currently, the code to be merged is manually detected and adjusted, and then merged into the main code.
[0004] However, manual adjustment of the code to be merged has low accuracy and low efficiency. Summary of the invention
[0005] The present invention provides a code merging method, device, equipment and medium to improve the accuracy of code merging.
[0006] In a first aspect, an embodiment of the present invention provides a code merging method, the method comprising:
[0007] Get the trunk code and the code to be merged;
[0008] Detect the code to be merged and obtain at least one code fault information;
[0009] Generate at least one fault prompt message according to each code fault information and the main code, and send it to the code detection model to obtain code repair information;
[0010] Repair the code to be merged according to the code repair information, and merge the repaired code to be merged into the main code.
[0011] In a second aspect, an embodiment of the present invention further provides a code merging device, the device comprising:
[0012] Code acquisition module, used to obtain the main code and the code to be merged;
[0013] A code detection module, used for detecting the code to be merged and obtaining at least one code fault information;
[0014] A prompt information generation module is used to generate at least one fault prompt information according to each code fault information and the main code, and send it to the code detection model to obtain code repair information;
[0015] The code merging module is used to repair the code to be merged according to the code repair information, and merge the repaired code to be merged into the main code.
[0016] In a third aspect, an embodiment of the present invention further provides a code merging device, the code merging device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to at least one processor; wherein,
[0019] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor can execute the code merging method of any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the code merging method of any embodiment of the present invention when executed.
[0021] The technical solution of the embodiment of the present invention obtains the main code and the code to be merged; detects the code to be merged to obtain at least one code fault information; generates at least one fault prompt information according to the code fault information and the main code, and sends it to the code detection model to obtain code repair information; repairs the code to be merged according to the code repair information, and merges the repaired code to be merged into the main code. The code to be merged can be detected and repaired through multi-bit data to ensure the accuracy of the code to be merged and ensure that the code to be merged can run safely after being merged into the main code.
[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 is a flowchart of a code merging method provided according to Embodiment 1 of the present invention;
[0025] Figure 2 is a flowchart of a code merging method provided according to Embodiment 2 of the present invention;
[0026] Figure 3 is a structural diagram of a code merging device provided according to an embodiment of the present invention;
[0027] Figure 4 It is a schematic diagram of the structure of a code merging device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] In the technical solution of the embodiment of the present invention, the acquisition, storage and application of the main code involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0031] The information collected is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0032] Embodiment 1
[0033] Figure 1 This is a flow chart of a code merging method provided in Embodiment 1 of the present invention. The embodiment of the present invention is applicable to the case of code merging, and the method can be executed by a code merging device, and the code merging device can be implemented in the form of hardware and / or software.
[0034] See also Figure 1 The code merging method shown includes:
[0035] S101, obtaining the main code and the code to be merged.
[0036] The trunk code can be used to describe the code to be added to, and the to-be-merged code can be used to describe the code to be merged into the trunk code.
[0037] Specifically, the trunk code usually exists as the core and stable version of the code project, representing the officially released version of the project or the code that has been fully tested and verified and can be used in the production environment. The code to be merged can come from the development, modification and improvement work carried out by developers on other branches such as functional branches or repair branches, which is a supplement and extension of the trunk code. The trunk code and the code to be merged are obtained in ways including but not limited to: text transmission, mouse selection or keyboard input, etc., which are not limited in the embodiments of the present invention.
[0038] S102: Detect the code to be merged and obtain at least one code fault information.
[0039] The code fault information may be description information of the fault detected by the code to be merged.
[0040] Specifically, the trunk code represents the core, stable, and deployable code of the code project. The trunk code should always remain stable and runnable, and only the code that has been fully tested, verified, and confirmed to not damage existing functions can be merged into the trunk code. In the process of merging the code to be merged into the trunk code, various risks may arise, such as merge conflicts, code quality issues, or functional abnormalities, which may affect the stability of the trunk code and the normal operation of the project. Therefore, in order to reduce the risk, the code to be merged needs to be detected. If the detection shows that the code to be merged corresponds to at least one code fault information, the code to be merged needs to be repaired according to each code fault information; if the detection shows that there is no code fault information for the code to be merged, it means that the code to be merged meets the merging requirements, and the code to be merged can be directly merged into the trunk code.
[0041] S103: Generate at least one fault prompt message according to each code fault information and the main code, and send it to the code detection model to obtain code repair information.
[0042] The fault prompt information may be description information of the code fault, which is used to be sent to the code detection big model so that the code detection big model generates code repair information according to the fault prompt information. The code detection big model may be a big model that can generate code repair information for the code fault. The code repair information may be used to describe the solution for repairing the fault corresponding to the code to be merged.
[0043] Specifically, at least one code fault corresponding to the code to be merged and the fault description information of each code fault can be determined based on the code fault information detected for the code to be merged. The code to be merged can rely on certain code structures, functional modules or library files in the trunk code. If the trunk code undergoes major changes, it may cause compatibility issues in the code to be merged, and corresponding adjustments and modifications are required. In addition, the code specifications, architecture design or business logic of the trunk code also have certain constraints on the code to be merged. The code to be merged needs to follow the relevant rules and requirements of the main branch to ensure the consistency and maintainability of the code. Therefore, according to the trunk code, the trunk code is detected to obtain the constraint information corresponding to the trunk code. According to the code fault information and the trunk code, the constraint information that the code to be merged needs to comply with and the fault information of the code to be merged can be determined, and fault prompt information is generated, prompting the code to detect that the model generates code repair information that complies with the constraint information and code faults according to the fault prompt information.
[0044] S104: Repair the code to be merged according to the code repair information, and merge the repaired code to be merged into the main code.
[0045] Specifically, the code repair information includes a repair plan for repairing at least one code fault corresponding to the code to be merged. According to the code repair information, the code to be merged is repaired according to the repair plan recommended by the code repair information to obtain the repaired and fault-free code to be merged. The repaired code to be merged is merged into the main code to ensure the stability of the main code operation and complete the repair or expansion of the main code.
[0046] The technical solution of the embodiment of the present invention obtains the main code and the code to be merged; detects the code to be merged to obtain at least one code fault information; generates at least one fault prompt information according to the code fault information and the main code, and sends it to the code detection model to obtain code repair information; repairs the code to be merged according to the code repair information, and merges the repaired code to be merged into the main code. The code to be merged can be detected and repaired through multi-bit data to ensure the accuracy of the code to be merged and ensure that the code to be merged can run safely after being merged into the main code.
[0047] Embodiment 2
[0048] Figure 2 This is a flow chart of a code merging method provided in Embodiment 2 of the present invention. Based on the above embodiments, this embodiment of the present invention optimizes and improves the code merging operation.
[0049] Furthermore, "based on each code fault information and the main code, generate at least one fault prompt information, send it to the code detection model, and obtain code repair information" is refined into "for each code fault information, determine the fault association data and fault template corresponding to the code fault information based on the code fault information and the main code; determine at least one fault prompt word based on the fault association data; merge each fault prompt word corresponding to the code fault information with the fault template to obtain fault prompt information; send the fault prompt information to the code detection model to obtain code repair information" to improve the code merging operation.
[0050] It should be noted that for the parts not described in detail in the embodiments of the present invention, reference may be made to the descriptions of other embodiments.
[0051] See also Figure 2 The code merging method shown includes:
[0052] S201, obtaining the main code and the code to be merged.
[0053] S202: Detect the code to be merged and obtain at least one code fault information.
[0054] S203. For each code fault information, determine the fault association data and fault template corresponding to the code fault information according to the code fault information and the trunk code.
[0055] Among them, fault-related data can be used to describe data associated with code fault information, to expand code fault information, to describe code faults in more detail and comprehensively, and to provide complete code fault information. A fault template can be a predefined prompt word structure that contains fillable placeholders, which is convenient for users to customize according to specific needs to guide the code detection model to generate specific types of outputs.
[0056] Specifically, for each code fault information, according to the code fault information and the main code, by identifying the code fault information and the main code, the code fault type, code fault location, code dependency framework structure or code fault keywords and other information are determined. According to the above code fault content, the fault-related data associated with the above code fault content is queried to expand and improve the code fault information. For example, the fault-related data can be the code logical structure information corresponding to the fault, the description information of the type of code fault, the cause of the code fault or the solution information of the code fault, etc. According to the fault feature information provided by the code fault information and the main code, the fault template is determined. There is no need to write complex prompt words from scratch. By selecting the appropriate fault template corresponding to the code fault information and filling in the specific content, effective prompt information can be quickly constructed, saving time and energy. The fault template can also be reused in different scenarios and tasks, which improves the reuse rate of the fault template and reduces duplication of work.
[0057] S204: Determine at least one fault prompt word according to the fault association data.
[0058] The fault prompt word may be a prompt word describing the fault of the code to be merged.
[0059] Specifically, the fault prompt word can be a short text instruction that guides the code detection model to perform a specific task. It can clearly inform the code detection model of the specific task that the user expects it to perform, and supplement the code detection model with the background information, conditional restrictions or specific requirements required to complete the task, so as to help the code detection model better understand the task context and requirements, thereby generating more accurate and more in line with the needs. A keyword library can be determined, and based on the fault-related data, the fault-related data can be searched to see whether there are keywords in the keyword library. If there is at least one keyword that is the same as that in the keyword library, each keyword is determined as a fault prompt word.
[0060] S205: Merge each fault prompt word corresponding to the code fault information with the fault template to obtain fault prompt information.
[0061] Specifically, the fault prompt words can be analyzed to extract key feature words, and then the matching positions can be found in the fault template for replacement or filling. For example, if the fault prompt word is "memory overflow error" and the fault template has the format of "[error type] occurs in [specific module]", "memory overflow error" can be filled in the position of "[error type]" to form the fusion result of "memory overflow error occurs in [specific module]", and then the content of "specific module" can be determined according to the specific situation. It is also possible to identify the logical relationship between fault prompt words and between fault prompt words and fault templates, such as causal relationship or parallel relationship, and then fuse according to these logical relationships. For example, the fault prompt words are "file read failure" and "insufficient disk space", and the fault template is "due to [reason], leading to [result]", which can be fused into "due to insufficient disk space, file read failure". It is also possible to use natural language processing technology to extract features from fault prompt words and fault templates, convert them into vector representations, and then learn how to fuse these vectors through machine learning algorithms. For example, you can use methods such as the bag-of-words model or TF-IDF to extract text features, then use the embedding layer in deep learning to convert them into low-dimensional vectors, and finally perform fusion operations through a neural network to obtain fault prompt information.
[0062] S206: Send the fault prompt information to the code detection model to obtain code repair information.
[0063] Specifically, the fault prompt information is sent to the trained code detection model, so that the code detection model performs syntax and semantic analysis on the fault prompt information and identifies the core requirements and expected outputs described in the fault prompt information. The code detection model determines the code content that needs to be repaired, the type of code fault that needs to be repaired, the repair specification corresponding to the repair code fault type, and the code after the code repair is completed through the fault prompt information.
[0064] S207: Repair the code to be merged according to the code repair information, and merge the repaired code to be merged into the main code.
[0065] The embodiment of the present invention determines the fault association data and fault template corresponding to each code fault information according to the code fault information and the trunk code; determines at least one fault prompt word according to the fault association data; merges each fault prompt word corresponding to the code fault information with the fault template to obtain fault prompt information; sends the fault prompt information to the code detection big model to obtain code repair information, guides the code detection big model to accurately identify the code fault information through the fault prompt words and fault template, and generates a repair plan corresponding to the code fault information, so that the code to be merged can perform fault maintenance and ensure the accuracy of the code to be merged.
[0066] Optionally, fault-associated data corresponding to the code fault information is determined based on the code fault information and the trunk code, including: identifying at least one fault keyword based on the code fault information; determining at least one fault information type corresponding to the code fault information based on each fault keyword and the trunk code; obtaining fault description information corresponding to each fault information type; and determining each fault description information as the fault-associated data corresponding to the code fault information.
[0067] The fault keyword may be a keyword extracted from the code fault information, and is used to narrow the scope of the fault information. The fault information type may be used to describe the type of the code fault.
[0068] Specifically, at least one fault keyword is identified based on the code fault information. According to each fault keyword and the trunk code, key feature information is extracted, the fault information range is divided, and the fault information type corresponding to the code fault information is determined. The fault information type is obtained by querying to obtain the fault description information, and the query method includes but is not limited to: sequential search algorithm, block search algorithm, hash search algorithm or tree table search algorithm, etc., which is not limited in the embodiment of the present invention. Each fault description information is determined as the fault association data corresponding to the code fault information.
[0069] By identifying at least one fault keyword based on the code fault information; determining at least one fault information type corresponding to the code fault information based on each fault keyword and the trunk code; obtaining fault description information corresponding to each fault information type; determining each fault description information as fault-related data corresponding to the code fault information, and by obtaining the fault-related data corresponding to the code fault information, the description information of the code fault is expanded, making the description information of the fault more complete, thereby facilitating the generation of a more accurate repair plan.
[0070] Optionally, the code to be merged is detected to obtain at least one code fault information, including: obtaining at least one fault type, fault conditions and fault marks corresponding to each fault type; detecting the code to be merged according to each fault condition, determining at least one eligible code block and the fault type of each eligible code block; for each eligible code block, marking each eligible code block according to the fault mark corresponding to the eligible code block, and determining at least one marked code block; determining each marked code block corresponding to the code to be merged, the fault type and fault condition corresponding to each marked code block as the code fault information of the code to be merged.
[0071] Among them, the fault type can be used to describe the type of fault. The fault condition can be a condition that needs to be met when determining the fault type. The fault tag can be used to mark the code of the fault.
[0072] Specifically, at least one fault type, a fault condition corresponding to each fault type, and a fault mark are obtained. The code to be merged is detected according to each fault condition, at least one code block that meets the fault condition is determined, the fault of the code block is determined, and the fault type corresponding to the code block is determined. For each qualified code block, each qualified code block is marked according to the fault mark corresponding to the fault type of the qualified code block, and at least one marked code block is determined. The marked code blocks corresponding to the code to be merged, the fault type and fault condition corresponding to each marked code block are determined as the code fault information of the code to be merged, which code blocks in the code to be merged are faulty, the fault type and fault cause of each code block can be determined.
[0073] By obtaining at least one fault type, fault conditions and fault marks corresponding to each fault type; detecting the code to be merged according to each fault condition, determining at least one eligible code block and the fault type of each eligible code block; for each eligible code block, marking each eligible code block according to the fault mark corresponding to the eligible code block, and determining at least one marked code block; determining each marked code block corresponding to the code to be merged, the fault type and fault condition corresponding to each marked code block as the code fault information of the code to be merged, the faulty code block can be marked, the code fault location, fault cause and fault type can be determined, so as to find the corresponding solution for each fault information and perform targeted repair, thereby ensuring the accuracy of the code.
[0074] Optionally, the code to be merged is repaired according to the code repair information, and the repaired code to be merged is merged into the main code, including: obtaining connection interface data corresponding to the code to be merged; obtaining at least one repair scheme in the code repair information and the repair code rate corresponding to each repair scheme; selecting the repair scheme corresponding to the lowest repair code rate among each repair code rate, repairing the code to be merged, and obtaining the repaired code to be merged; merging the repaired code to be merged into the main code according to the repaired code to be merged and the connection interface data.
[0075] The connection interface data may be the description information of the interface, connection position and connection mode to which the code to be merged should be connected. The repair code rate may be the ratio of the number of codes modified in the code to be merged to the code to be merged.
[0076] Specifically, the connection interface data corresponding to the code to be merged is obtained, and the interface, connection position and connection method to which the code to be merged should be connected are determined. The code detection model generates code repair information according to the fault prompt information. At least one repair scheme in the code repair information and the repair code rate corresponding to each repair scheme are obtained. The repair scheme corresponding to the minimum value in the repair code rate is selected from each repair code rate, and the code to be merged is repaired to obtain the repaired code to be merged. The repaired code to be merged is merged according to the connection interface, connection position and connection method corresponding to the connection interface data, and the repaired code to be merged is merged into the trunk code.
[0077] By obtaining connection interface data corresponding to the code to be merged; obtaining at least one repair scheme in the code repair information and the repair code rate corresponding to each repair scheme; selecting the repair scheme corresponding to the lowest repair code rate among the repair code rates, repairing the code to be merged, and obtaining the repaired code to be merged; merging the repaired code to be merged into the trunk code according to the repaired code to be merged and the connection interface data, and searching for the scheme with the least code modification in at least one repair scheme to perform code repair, thereby reducing the amount of data to be processed and improving the efficiency of code merging.
[0078] Optionally, before obtaining the code to be merged, the process includes: obtaining at least one static detection type and a repair plan corresponding to each static detection type; performing static detection on the code to be merged to obtain at least one static fault; according to each static fault, querying the static detection type corresponding to each static fault; repairing each static fault according to the repair plan of the static detection type corresponding to each static fault, to obtain the repaired code to be merged.
[0079] The static detection type may be a detection type for statically detecting the code to be merged, and the static fault may be used to describe a fault detected by the code to be merged according to the static detection type.
[0080] Specifically, obtain at least one static detection type and the repair solution corresponding to each static detection type. The static detection type can be: incorrect code naming, incorrect code reference method, or code length exceeds the limit, etc. Perform static detection on the code to be merged to obtain at least one static fault. The static faults can be the same or different. According to each static fault, query the static detection type corresponding to each static fault. The query method can be depth-first traversal or breadth-first traversal, etc. Repair each static fault according to the repair solution of the static detection type corresponding to each static fault to obtain the repaired code to be merged.
[0081] By obtaining at least one static detection type and a repair plan corresponding to each static detection type; performing static detection on the code to be merged to obtain at least one static fault; according to each static fault, querying the static detection type corresponding to each static fault; repairing each static fault according to the repair plan of the static detection type corresponding to each static fault, to obtain the repaired code to be merged, first perform static detection to preliminarily detect the code to be merged, thereby reducing the amount of code to be detected and improving the efficiency of code detection.
[0082] Optionally, the code detection large model is trained through the following steps: obtaining at least one code knowledge text, the code knowledge text including: code fault type, code fault description information, code specification and code correct template; vectorizing the code fault type, code fault description information, code specification and code correct template in each code knowledge text to obtain at least one feature vector; storing each feature vector in a code knowledge base for training to obtain the code detection large model.
[0083] The code knowledge text may be a collection of various description information of the code.
[0084] Specifically, at least one code knowledge text is obtained, and the code knowledge text includes: code fault type, code fault description information, code specification and code correct template. The code fault type, code fault description information, code specification and code correct template in each code knowledge text are vectorized to obtain at least one feature vector, and each feature vector is stored in a code knowledge base. The code detection model is trained through the code knowledge base, and the code knowledge base provides rich training data to help the code detection model better learn the specific information in the code fault detection set and code repair field. In the reasoning stage, the code detection model can quickly retrieve relevant information in the code knowledge base and generate a more accurate repair plan.
[0085] The code detection big model is trained through the following steps: obtaining at least one code knowledge text, the code knowledge text includes: code fault type, code fault description information, code specification and code correct template; vectorizing the code fault type, code fault description information, code specification and code correct template in each code knowledge text to obtain at least one feature vector; storing each feature vector in a code knowledge base for training to obtain a code detection big model, which can obtain content in a specific field, so that the code detection big model can more accurately generate corresponding repair information according to the code fault, thereby improving the success rate of repairing the code to be merged.
[0086] Embodiment 3
[0087] Figure 3This is a schematic diagram of the structure of a code merging device provided in Embodiment 3 of the present invention. The embodiment of the present invention is applicable to the case of code merging, the device can execute the code merging method, and the device can be implemented in the form of hardware and / or software.
[0088] See also Figure 3 The code merging device shown includes: a code acquisition module 301, a code detection module 302, a prompt information generation module 303 and a code merging module 304, wherein:
[0089] The code acquisition module 301 is used to acquire the main code and the code to be merged;
[0090] A code detection module 302, configured to detect the code to be merged and obtain at least one code fault information;
[0091] The prompt information generating module 303 is used to generate at least one fault prompt information according to each code fault information and the main code, and send it to the code detection big model to obtain code repair information;
[0092] The code merging module 304 is used to repair the code to be merged according to the code repair information, and merge the repaired code to be merged into the main code.
[0093] The technical solution of the embodiment of the present invention obtains the main code and the code to be merged; detects the code to be merged to obtain at least one code fault information; generates at least one fault prompt information according to the code fault information and the main code, and sends it to the code detection model to obtain code repair information; repairs the code to be merged according to the code repair information, and merges the repaired code to be merged into the main code. The code to be merged can be detected and repaired through multi-bit data to ensure the accuracy of the code to be merged and ensure that the code to be merged can run safely after being merged into the main code.
[0094] Optionally, the prompt information generating module 303 includes:
[0095] A fault information acquisition unit, for determining, for each code fault information, fault associated data and a fault template corresponding to the code fault information according to the code fault information and the trunk code;
[0096] A prompt word determination unit, used to determine at least one fault prompt word according to the fault association data;
[0097] An information fusion unit, used to fuse each fault prompt word corresponding to the code fault information with the fault template to obtain fault prompt information;
[0098] The repair information acquisition unit is used to send the fault prompt information to the code detection model to obtain code repair information.
[0099] Optionally, the fault information acquisition unit is specifically used to:
[0100] According to the code fault information, at least one fault keyword is identified;
[0101] Determine at least one fault information type corresponding to the code fault information according to each fault keyword and trunk code;
[0102] Obtain the fault description information corresponding to each fault information type;
[0103] Each fault description information is determined as fault associated data corresponding to the code fault information.
[0104] Optionally, the code detection module 302 is specifically used for:
[0105] Obtain at least one fault type, a fault condition corresponding to each fault type, and a fault mark;
[0106] Detect the code to be merged according to each fault condition, and determine at least one code block that meets the condition and the fault type of each code block that meets the condition;
[0107] For each qualified code block, marking each qualified code block according to a fault mark corresponding to the qualified code block, and determining at least one marked code block;
[0108] Each marked code block corresponding to the code to be merged, the fault type and the fault condition corresponding to each marked code block are determined as the code fault information of the code to be merged.
[0109] Optionally, the code merging module 304 is specifically used for:
[0110] Get the connection interface data corresponding to the code to be merged;
[0111] Obtaining at least one repair scheme in the code repair information and a repair code rate corresponding to each repair scheme;
[0112] Selecting a repair solution corresponding to the lowest repair code rate from among the repair code rates, repairing the code to be merged, and obtaining the repaired code to be merged;
[0113] Based on the repaired code to be merged and the connection interface data, merge the repaired code to be merged into the main code.
[0114] Optionally, the code merging device further includes:
[0115] A repair solution acquisition module, used to obtain at least one static detection type and a repair solution corresponding to each static detection type before obtaining the code to be merged;
[0116] A static fault determination module, used for performing static detection on the code to be merged to obtain at least one static fault;
[0117] A type query module is used to query the static detection type corresponding to each static fault according to each static fault;
[0118] The merge code repair module is used to repair each static fault according to the repair solution of the static detection type corresponding to each static fault, and obtain the repaired code to be merged.
[0119] Optionally, a large code detection model is trained by the following steps:
[0120] Obtain at least one code knowledge text, the code knowledge text including: code fault type, code fault description information, code specification and code correct template;
[0121] Vectorize the code fault type, code fault description information, code specification and code correct template in each code knowledge text to obtain at least one feature vector;
[0122] Each feature vector is stored in a code knowledge base for training to obtain a large code detection model.
[0123] The code merging device provided in the embodiment of the present invention can execute the code merging method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the code merging method.
[0124] Embodiment 4
[0125] Figure 4 A schematic structural diagram of a code merging device 400 that can be used to implement an embodiment of the present invention is shown.
[0126] like Figure 4 As shown, the code merging device 400 includes at least one processor 401, and a memory connected to the at least one processor 401, such as a read-only memory (ROM) 402, a random access memory (RAM) 403, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 401 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 402 or the computer program loaded from the storage unit 408 to the random access memory (RAM) 403. In RAM403, various programs and data required for the operation of the code merging device 400 can also be stored. The processor 401, ROM402 and RAM403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0127] Multiple components in the code merging device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the code merging device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0128] Processor 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of processor 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. Processor 501 performs the various methods and processes described above, such as a code merging method.
[0129] In some embodiments, the code merging method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the code merging device 400 via the ROM 402 and / or the communication unit 409. When the computer program is loaded into the RAM 403 and executed by the processor 401, one or more steps of the code merging method described above may be performed. Alternatively, in other embodiments, the processor 401 may be configured to perform the code merging method in any other suitable manner (e.g., by means of firmware).
[0130] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0131] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0132] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0133] To provide interaction with a user, the systems and techniques described herein may be implemented on a code merging device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the code merging device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0134] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0135] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS (Virtual Private Server) services.
[0136] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0137] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A code merging method, characterized in that: The method comprises: Get the trunk code and the code to be merged; Detecting the code to be merged to obtain at least one code fault information; Generate at least one fault prompt information according to each of the code fault information and the trunk code, and send it to the code detection model to obtain code repair information; The code to be merged is repaired according to the code repair information, and the repaired code to be merged is merged into the main code.
2. The method according to claim 1, characterized in that The generating at least one fault prompt information according to each of the code fault information and the trunk code, sending the information to the code detection big model, and obtaining the code repair information includes: For each of the code fault information, determine the fault associated data and the fault template corresponding to the code fault information according to the code fault information and the trunk code; Determining at least one fault prompt word according to the fault-related data; Merging the fault prompt words corresponding to the code fault information with the fault template to obtain fault prompt information; The fault prompt information is sent to the code detection model to obtain code repair information.
3. The method according to claim 2, characterized in that The determining, according to the code fault information and the trunk code, fault-related data corresponding to the code fault information comprises: According to the code fault information, identifying at least one fault keyword; Determine at least one fault information type corresponding to the code fault information according to each of the fault keywords and the trunk code; Obtaining fault description information corresponding to each fault information type; Each of the fault description information is determined as the fault association data corresponding to the code fault information.
4. The method according to claim 1, characterized in that The detecting the code to be merged to obtain at least one code fault information includes: Obtain at least one fault type, a fault condition corresponding to each of the fault types, and a fault mark; Detect the code to be merged according to each of the fault conditions, and determine at least one code block that meets the condition and the fault type of each of the code blocks that meet the condition; For each of the qualified code blocks, marking each of the qualified code blocks according to a fault mark corresponding to the qualified code block, and determining at least one marked code block; The marked code blocks corresponding to the code to be merged, the fault type and fault condition corresponding to each marked code block are determined as the code fault information of the code to be merged.
5. The method according to claim 1, characterized in that The step of repairing the code to be merged according to the code repair information and merging the repaired code to be merged into the main code includes: Obtaining connection interface data corresponding to the code to be merged; Obtaining at least one repair scheme in the code repair information and a repair code rate corresponding to each of the repair schemes; Selecting a repair solution corresponding to a lowest repair code rate from among the repair code rates, repairing the code to be merged, and obtaining a repaired code to be merged; According to the repaired code to be merged and the connection interface data, the repaired code to be merged is merged into the trunk code.
6. The method according to claim 1, characterized in that Before obtaining the code to be merged, the following steps are included: Obtain at least one static detection type and a repair solution corresponding to each of the static detection types; Performing static detection on the code to be merged to obtain at least one static fault; According to each of the static faults, query the static detection type corresponding to each of the static faults; Each of the static faults is repaired according to a repair solution of a static detection type corresponding to each of the static faults to obtain a repaired code to be merged.
7. The method according to claim 1, characterized in that The code detection model is trained by the following steps: Acquire at least one code knowledge text, wherein the code knowledge text includes: code fault type, code fault description information, code specification and code correct template; Vectorizing the code fault type, code fault description information, code specification and code correct template in each of the code knowledge texts to obtain at least one feature vector; Each of the feature vectors is stored in a code knowledge base for training to obtain a large code detection model.
8. A code merging device, characterized in that: The device comprises: Code acquisition module, used to obtain the main code and the code to be merged; A code detection module, used to detect the code to be merged and obtain at least one code fault information; A prompt information generation module, used to generate at least one fault prompt information according to each of the code fault information and the trunk code, and send it to the code detection model to obtain code repair information; The code merging module is used to repair the code to be merged according to the code repair information, and merge the repaired code to be merged into the main code.
9. A code merging device, characterized in that: The code merging device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the code merging method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the code merging method according to any one of claims 1 to 7 when executed.
Citation Information
Cited By
Code checking method and electronic equipment
CN121523728A