Code hook-based code version verification method, system and equipment and medium
By introducing verification mechanisms of code hooks and collaboration platforms in the code base, the problem of miscommitting code in collaborative development in multi-teams is solved, and more efficient development and management is achieved.
Patent Information
- Application Number
- CN202411518900.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-25
AI Technical Summary
In multi-team collaborative development, developers are prone to missubmitting code to the wrong version or branch, resulting in delays in progress and increased management costs.
Using a code version verification method based on code hooks, the code base, code hook and collaboration platform work together to verify the version and branches of code submission in real time to ensure that the code is submitted to the correct location.
It effectively reduces the occurrence of missed submissions, improves development efficiency and collaboration efficiency, and reduces management costs.
Smart Images

Figure CN119512613A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language, and in particular to a code version verification method, system, computer equipment and computer-readable storage medium based on code hooks. Background Art
[0002] With the development of science and technology, applications are becoming more and more popular, and the demand for software development is also increasing. In large-scale software development projects, it is common for multiple teams to collaborate on development. Multiple teams collaborate on product iteration, and product iteration is based on versions. It is also common for multiple versions to coexist. For example, when the V1 version is submitted for testing, developers can develop the functions of the V2 version. One version corresponds to a main code branch, which is shared by multiple teams. However, when multiple people and multiple versions are collaboratively developed on the same branch, it is occasionally the case that a developer submits the wrong code, such as submitting the next version of the code to the branch of this version, thereby affecting the code of other developers, and even causing the code of other developers to be unable to be restored, thereby delaying the progress. If developers are not allowed to submit directly to the version branch, but instead submit requests and have them reviewed by the team leader, although it can effectively reduce erroneous submissions, it will greatly increase the workload, increase management costs, and reduce development efficiency.
[0003] Therefore, how to effectively reduce erroneous submissions while improving development efficiency has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of the present invention is to provide a code version verification method, device, equipment and computer-readable storage medium based on code hooks, aiming to improve development efficiency while effectively reducing erroneous submissions.
[0005] To achieve the above object, the present invention provides a code version verification method based on a code hook, the code version verification method is applied to a code version verification system, the code version verification system includes a code library, a code hook and a collaboration platform, the code version verification method includes the following steps:
[0006] When receiving the code submission instruction of the target code, the code library obtains the current version parameter of the target code, and sends the current code version number in the current version parameter to the code hook;
[0007] The code hook sends the current code version number to the collaboration platform, and obtains the standard version information corresponding to the target code from the collaboration platform;
[0008] The code hook performs version and / or branch verification on the target code based on the current version parameter and the standard version information to obtain a first verification result, and feeds the first verification result back to the code library;
[0009] The code library processes the code submission instruction based on the first verification result.
[0010] In addition, to achieve the above object, the present invention also provides a code version verification system, the code version verification system comprising:
[0011] The code library is used to obtain the current version parameters of the target code when receiving the code submission instruction of the target code, and send the current code version number in the current version parameters to the code hook;
[0012] A code hook, used to send the current code version number to the collaboration platform, and obtain the standard version information corresponding to the target code from the collaboration platform;
[0013] A collaboration platform, used for the code hook to perform version and / or branch verification on the target code based on the current version parameter and the standard version information, obtain a first verification result, and feed the first verification result back to the code library;
[0014] The code library is further used to process the code submission instruction based on the first verification result.
[0015] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer device, which includes a processor, a memory, and a code version verification program based on a code hook stored on the memory and executable by the processor, wherein when the code version verification program based on a code hook is executed by the processor, the steps of the code version verification method based on a code hook as described above are implemented.
[0016] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a code version verification program based on a code hook is stored, wherein when the code version verification program based on a code hook is executed by a processor, the steps of the code version verification method based on a code hook as described above are implemented.
[0017] The present application provides a code version verification method based on code hooks, the code version verification method is applied to a code version verification system, the code version verification system includes a code library, a code hook and a collaboration platform, the code version verification method obtains the current version parameters of the target code when receiving a code submission instruction of the target code through the code library, and sends the current code version number in the current version parameters to the code hook; the code hook sends the current code version number to the collaboration platform, and obtains the standard version information corresponding to the target code from the collaboration platform; the code hook performs version and / or branch verification on the target code based on the current version parameters and the standard version information, obtains a first verification result, and feeds the first verification result back to the code library; the code library processes the code submission instruction based on the first verification result. In the above manner, this application intercepts the submitted target code through code hooks before submitting the submitted code to the code library, and performs version or branch checks on the intercepted target code, combining the characteristics of the code library and the collaboration platform, so that the code library automatically intercepts the submitted code for inspection when docking with various different collaboration platforms, thereby reducing the risk of developers mistakenly submitting code to other versions or other branches. In the context of multi-team and multi-version parallel development in the current software development industry, while improving collaboration efficiency and development efficiency, it also reduces management costs, thereby achieving improved development efficiency while effectively reducing erroneous submissions. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flowchart of a first embodiment of a code version verification method based on a code hook of the present invention;
[0019] Figure 2 It is a flowchart of a second embodiment of a code version verification method based on a code hook of the present invention;
[0020] Figure 3 It is a flowchart of a third embodiment of a code version verification method based on a code hook of the present invention;
[0021] Figure 4 This is a schematic diagram of the code version verification process of the present invention;
[0022] Figure 5 It is a schematic diagram of a code version verification device based on code hooks of the present invention;
[0023] Figure 6 The figure is a schematic diagram of the hardware structure of a computer device involved in an embodiment of the present invention.
[0024] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0027] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0028] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0029] The code version verification method based on code hooks involved in the embodiment of the present invention is mainly applied to computer equipment, which can be a device with display and processing functions such as a PC, a portable computer, and a mobile terminal.
[0030] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0031] Reference Figure 1 , Figure 1 Schematic diagram of the flow of the first embodiment of the code version verification method based on code hooks of the present invention.
[0032] like Figure 1 As shown, an embodiment of the present invention provides a code version verification method based on code hooks, and the code version verification method is applied to a code version verification system, and the code version verification system includes a code library, a code hook, and a collaboration platform. The code version verification method based on code hooks includes steps S10 to S40.
[0033] Step S10: When receiving the code submission instruction of the target code, the code library obtains the current version parameter of the target code, and sends the current code version number in the current version parameter to the code hook;
[0034] Multiple teams collaborate on product iterations, and product iterations are based on versions. It is common for multiple versions to coexist. For example, when V1 is submitted for testing, developers can develop the functions of V2. One version corresponds to a main code branch, which is shared by multiple teams. However, when multiple people and multiple versions are collaboratively developed on the same branch, it is occasionally the case that a developer submits the wrong code, such as submitting the next version of the code to the branch of the current version, which affects the code of other developers and even makes the code of other developers unable to be restored, thus causing progress delays. If developers are not allowed to submit directly to the version branch, but instead submit requests and have them reviewed by the team leader, although it can effectively reduce erroneous submissions, it will greatly increase the workload, increase management costs, and reduce development efficiency.
[0035] At present, code base management tools and collaboration platforms are often separated. Each company has its own collaboration platform with different management methods, and code base management tools cannot be connected to various collaboration platforms. In order to solve the above problems, this application provides a code version verification method based on code hooks, which combines the characteristics of code base and collaboration platform, so that when the code base is connected to various collaboration platforms, it automatically intercepts the submitted code for inspection, thereby reducing the risk of developers mistakenly submitting code to other versions or other branches.
[0036] Specifically, when receiving a code submission instruction, the code library implements version or branch verification based on the feature extension of the code hook, that is, calling the code hook to perform version or branch verification on the submitted code, thereby verifying the version or branch of the submitted code. This application involves three parts: developers, code library, and submission hook judgment.
[0037] The developer submits the code to be submitted and sends a code submission instruction to the code library. When the code library receives the code submission instruction, it obtains the current version parameters of the target code, where the current version parameters include the code library address, the code submitter, the branch to which the code belongs, and the version number corresponding to the code. For example, submitter: Zhang San, version number: 20240101, code library address: address1, branch: main_branch_v1.
[0038] The current code version number in the current version parameter is sent to the code hook. When the code library receives the developer's submission, the submission hook method is called with the current version parameter.
[0039] Step S20: the code hook sends the current code version number to the collaboration platform, and obtains the standard version information corresponding to the target code from the collaboration platform;
[0040] In this embodiment, the collaboration platform is used to store project information of each code project, record project progress, define version plans of the code project, development content corresponding to the code, and version and branch information corresponding to the code.
[0041] The code hook sends the current code version number to the collaboration platform, and receives the standard version information corresponding to the target code fed back by the collaboration platform, wherein the standard version information is the version and branch corresponding to the code.
[0042] Furthermore, before step S20, the method further includes:
[0043] The code repository sends the branch format in the current version parameter to the code hook;
[0044] The code hook determines the code type of the target code based on the branch format;
[0045] If the code type is a personal branch, the code hook generates a verification pass and sends the verification result of the verification pass to the code library.
[0046] Furthermore, after the code hook determines the code type of the target code based on the branch format, it also includes:
[0047] If the code type is a version main branch, the following is performed: the code hook sends the current code version number to the collaboration platform, and receives standard version information fed back by the collaboration platform.
[0048] In this embodiment, the developer's operation on the personal branch has no impact on the team. Therefore, the code library first sends the branch format in the current version parameters to the code hook for branch judgment, that is, the code hook first determines whether the branch format of the submitted code is a personal branch. If it is a personal branch, there is no need to continue to verify, and the verification can be returned successfully. If it is a collaborative main branch, not a personal branch, execute: the code hook sends the current code version number to the collaboration platform, and receives the standard version information fed back by the collaboration platform. Among them, the version main branch format is main_branch_**, and if it is not this format, it is a personal branch.
[0049] Step S30: the code hook performs version and / or branch verification on the target code based on the current version parameter and the standard version information to obtain a first verification result, and feeds the first verification result back to the code library;
[0050] In this embodiment, the code hook verifies the current version parameters based on the standard version information, that is, determines whether the version number and branch in the current version parameters match the version number and branch in the standard version information. If the current version parameters match the standard version information, the verification is successful; if the current version parameters do not match the standard version information, the verification fails. The verification result of success or failure is used as the first verification result, and the first verification result is fed back to the code library.
[0051] Furthermore, the code hook searches the standard version information based on the current code version number, and if the standard version information contains version information that matches the current code version number, the current code library address in the current version parameter is further obtained, and based on the current code library address, the standard version branch information corresponding to the current code library address is further determined in the standard version information;
[0052] Based on the current code library address and the current version branch information in the current version parameters, a comparison is performed with the standard code library address and the standard version branch information in the standard version information. If the current code library address in the current version parameters matches the current version branch information, and matches the standard code library address and the standard version branch information in the standard version information, then it is determined that the version or branch information verification of the target code is successful; otherwise, it is determined that the version or branch information verification of the target code is failed.
[0053] Step S40: The code library processes the code submission instruction based on the first verification result.
[0054] Furthermore, the code library processes the code submission instruction based on the verification result, specifically including:
[0055] When the verification result is successful, the code library receives the target code, updates the code stored in the library based on the target code, and generates prompt information indicating successful submission;
[0056] When the verification result is a verification failure, the code library rejects the target code and generates a prompt message indicating submission failure.
[0057] In this embodiment, if the verification match is successful, the verification success is returned to the code library, the code library receives this submission, the main branch code changes, and the submission success is returned to the developer; if the verification match fails, the verification failure is returned to the code library, the code library rejects this submission, the main branch code remains unchanged, and the submission failure is returned to the developer.
[0058] Specifically, when the first verification result is a successful verification, it means that the version number in the current version parameter matches the branch, the code library receives this submission, updates the corresponding main branch code or the corresponding version code in the code library according to the target code, and feeds back a prompt message of successful submission to the code submitter; when the first verification result is a failed verification, it means that the version number in the current version parameter does not match the branch, the target code submitted this time is submitted abnormally, the code library rejects this submission, and feeds back a prompt message of failed submission to the code submitter.
[0059] Furthermore, a failure reason reminder can be generated based on the abnormal comparison result for the submitter to confirm the abnormality.
[0060] The present embodiment provides a code version verification method based on a code hook, and the code version verification method is applied to a code version verification system, and the code version verification system includes a code library, a code hook and a collaboration platform. When receiving a code submission instruction of a target code, the code version verification method obtains the current version parameters of the target code through the code library, and sends the current code version number in the current version parameters to the code hook; the code hook sends the current code version number to the collaboration platform, and obtains the standard version information corresponding to the target code from the collaboration platform; the code hook performs version and / or branch verification on the target code based on the current version parameters and the standard version information, obtains a first verification result, and feeds the first verification result back to the code library; the code library processes the code submission instruction based on the first verification result. Through the above method, this application intercepts the submitted target code before submitting the submitted code to the code library, and performs version or branch check on the intercepted target code, combining the characteristics of the code library and the collaboration platform, so that the code library automatically intercepts the submitted code for inspection when docking with various different collaboration platforms, thereby reducing the risk of developers mistakenly submitting code to other versions or other branches. In the context of multi-team and multi-version parallel development in the current software development industry, while improving collaboration efficiency and development efficiency, it also reduces management costs, thereby achieving improved development efficiency while effectively reducing erroneous submissions.
[0061] Reference Figure 2 , Figure 2 Schematic diagram of the flow of the second embodiment of the code version verification method based on code hooks of the present invention.
[0062] Based on the above Figure 1 In the embodiment shown, in this embodiment, the step S20 specifically includes:
[0063] Step S21, the code hook sends the current code version number to the collaboration platform, and receives the version plan and version branch information of the project to which the target code belongs fed back by the collaboration platform;
[0064] Step S22, the code hook determines the format of the version plan and the version branch information based on the standard version information specification;
[0065] Step S23, when there is a format in the version plan and the version branch information that does not conform to the standard version information specification, the code hook converts the version plan and / or version branch information that does not conform to the specification based on the format conversion model;
[0066] Step S24: the code hook extracts the standard version information from the converted version plan and version branch information based on the version information extraction template.
[0067] In this embodiment, in order to realize automatic interception and inspection of submitted codes, automatic extraction of standard version information is further realized.
[0068] Specifically, the code hook first sends the current code version number to the collaboration platform, and obtains the version plan and version branch information of the project to which the target code belongs in the collaboration platform. Since each company has its own collaboration platform, different collaboration platforms have different management methods, and different developers have different writing habits, the formats of version plans and version branch information in different collaboration platforms are different. The code hook first determines whether the version plan and the version branch information comply with the standard version information specifications. If they comply with the standard version information specifications, the code hook directly extracts information from the version plan and the version branch information according to the version information extraction template to generate standard version information. If it does not comply with the standard version information specifications, the version plan and the version branch information are converted based on the format conversion model.
[0069] Among them, model training is carried out through version plans and version branch information corresponding to various formats.
[0070] Specifically, a mapping relationship between a preset first format text and a preset target format text is obtained in advance, and the first format text is obtained; the first format text is annotated according to the mapping relationship to obtain a label of the first format text, and the label is the target format text corresponding to the first format text; the format conversion model is trained according to the first format text and the label to obtain a trained format conversion model. Thus, the first format text is annotated through the mapping relationship to obtain the label of the first format text, and then the format conversion model is trained using the first format text and the label to obtain a trained format conversion model with high translation accuracy. By using the trained format conversion model for translation, the accuracy and efficiency of the translation of version plans and version branch information are improved.
[0071] In the above manner, the format conversion model is used to identify and convert version plans and version branch information in different formats, thereby automatically generating standard version information. Therefore, by combining the characteristics of the code library and the collaboration platform, the code library automatically intercepts the submitted code for inspection when connecting to various collaboration platforms, thereby reducing the risk of developers mistakenly submitting code to other versions or other branches, and further improving development efficiency.
[0072] Reference Figure 3 , Figure 3 4 is a flow chart of a third embodiment of a code version verification method based on code hooks according to the present invention.
[0073] Based on the above Figure 2 In the embodiment shown, in this embodiment, after step S30, the following steps are further included:
[0074] Step S50, the code hook sends a submission specification acquisition instruction to the collaboration platform, and receives code submission specification information fed back by the collaboration platform;
[0075] Step S60, the code hook performs submission specification verification on the target code based on the code submission specification information, obtains a third verification result, and feeds the third verification result back to the code library;
[0076] Step S70: The code library processes the code submission instruction based on the third verification result.
[0077] Furthermore, the code version verification method further includes:
[0078] The code library obtains the code submission user information and sends the submission user information to the code hook;
[0079] The code hook sends the current code version number to the collaboration platform, and receives a submitted user whitelist fed back by the collaboration platform;
[0080] The code hook performs submission permission verification on the target code based on the submission user whitelist and the submission user information, obtains a second verification result, and feeds the second verification result back to the code library;
[0081] The code library processes the code submission instruction based on the second verification result.
[0082] In this embodiment, code submission occurs frequently in both the development phase and the testing phase. Therefore, realizing automatic review of submitted code is an effective way to improve development efficiency while effectively reducing erroneous submissions. However, code repository management tools and collaboration platforms are often separate. Each company has its own collaboration platform with different management methods, and code repository management tools cannot be connected to various collaboration platforms. Therefore, by utilizing the characteristics of code hooks, the scalability of this solution can be improved, that is, multiple functions such as user permission verification, code format verification, and version branch verification can be flexibly implemented in the code submission hook.
[0083] Specifically, the branch and version of the submitted code can be checked in the code hook, and the authority of the submitter can be verified. Based on the verification development team's standard requirements for submitted information, the target code can be submitted to a standard verification. The number of submissions, frequency, amount of code, etc. submitted by the submitter can also be counted based on the code hook.
[0084] In a specific embodiment, Figure 4 As shown in the figure, developers can submit code (i.e., target code) to the code repository, where the submission information includes information such as the submitted code, submitter, corresponding version of the submitted code, corresponding branch, and code repository address. When the code repository receives the submitted code sent by the developer, it can call the code hook (i.e., the submission hook shown in the figure) to make a judgment based on the submitter, version, branch, and code repository address.
[0085] Since the developer's operation on the personal branch has no impact on the team, the operation on the main branch is likely to cause abnormalities in other codes of the team. Therefore, the submission hook first determines the personal branch and the main branch of the submitted code based on the format of the submitted code. If it is a personal branch, there is no need to continue to verify, and the verification can be returned successfully. If it is a main branch, not a personal branch, then execute: the code hook sends the current code version number to the collaboration platform, and receives the standard version information fed back by the collaboration platform. Among them, the main branch format of the version is main_branch_**, and if it is not in this format, it is a personal branch.
[0086] It is understandable that the format can also be judged based on the code revocation property, that is, the irrevocable code is verified, and the revocable code is directly verified and passed, so as to avoid unnecessary code occupying resources and further improve the verification efficiency;
[0087] Furthermore, format judgment can also be made based on the submission personnel's selection operation. For example, when the submission personnel chooses branch version verification, that is, when the submitted code carries a verification mark, the submitted code will be subject to branch version verification. Otherwise, the verification will pass directly to avoid unnecessary code occupying resources and further improve submission verification efficiency.
[0088] When the submitted code is the main branch, the submission hook determines the standard version information corresponding to the target code based on the current version number of the target code, that is, the submission hook first determines whether there is standard version information matching the current version number. If so, in the case where the branch in the standard version information is not unique, the submission hook determines whether the current code library address and the branch and version corresponding to the current code library address match the code library address, branch and version recorded in the standard version information based on the code library address of the target code. If all match, it is determined that the target code verification is successful, indicating that there is no abnormality in the target code submitted by the developer this time. The submission hook feeds back a verification success instruction to the code library so that the code library receives the developer's submission this time, updates the corresponding main branch code or corresponding version code in the code library according to the target code, and feeds back a prompt message of successful submission to the code submitter; if the branch does not match or the version does not match, the submission hook determines that the target code verification fails, indicating that the target code submitted this time is abnormal, and the submission hook feeds back a verification failure instruction to the code library so that the code library rejects this submission, and feeds back a prompt message of failed submission to the code submitter.
[0089] Through the above method, based on the characteristics of the code hook that can flexibly implement various functions, the scalability of the code version verification method provided by this application is improved, and the function of submitting permission verification is added to the submitter, which further reduces the risk of developers submitting code to other versions or other branches by mistake, and adds code format verification to the submitter, further reducing the risk of developers submitting wrong code. Therefore, by combining the characteristics of the code library and the collaboration platform, the code library automatically intercepts the submitted code for inspection when docking with various different collaboration platforms, thereby reducing the risk of developers submitting code to other versions or other branches by mistake, and further improving development efficiency.
[0090] See also Figure 5 , Figure 5 An embodiment of the present application provides a code version verification system 500, the code version verification system comprising:
[0091] The code library 10 is used to obtain the current version parameters of the target code when receiving the code submission instruction of the target code, and send the current code version number in the current version parameters to the code hook;
[0092] The code hook 20 is used to send the current code version number to the collaboration platform and obtain the standard version information corresponding to the target code from the collaboration platform;
[0093] The collaboration platform 30 is used for the code hook to perform version and / or branch verification on the target code based on the current version parameter and the standard version information, obtain a first verification result, and feed the first verification result back to the code library;
[0094] The code library 10 is further used to process the code submission instruction based on the first verification result.
[0095] Further, the code library is also used to send the branch format in the current version parameter to the code hook;
[0096] The code hook is also used to determine the code type of the target code based on the branch format;
[0097] If the code type is a version main branch, the following is performed: the code hook sends the current code version number to the collaboration platform, and receives standard version information fed back by the collaboration platform.
[0098] Furthermore, if the code type is a personal branch, the code hook is also used to determine whether the generation verification is passed, and send the verification result of the verification passing to the code library.
[0099] Furthermore, the code library is also used to obtain code submission user information and send the submission user information to the code hook;
[0100] Furthermore, the code hook is also used to send the current code version number to the collaboration platform, and receive a submitted user whitelist fed back by the collaboration platform;
[0101] Furthermore, the code hook is also used to perform submission permission verification on the target code based on the submission user whitelist and the submission user information, obtain a second verification result, and feed the second verification result back to the code library;
[0102] Furthermore, the code library is also used to process the code submission instruction based on the second verification result.
[0103] Furthermore, the code hook is also used to send a submission specification acquisition instruction to the collaboration platform, and receive code submission specification information fed back by the collaboration platform;
[0104] Furthermore, the code hook is also used to perform submission specification verification on the target code based on the code submission specification information, obtain a third verification result, and feed the third verification result back to the code library;
[0105] The code library processes the code submission instruction based on the third verification result.
[0106] Furthermore, the code hook sends the current code version number to the collaboration platform, and receives the version plan and version branch information of the project to which the target code belongs fed back by the collaboration platform;
[0107] The code hook determines the format of the version plan and the version branch information based on the standard version information specification;
[0108] When the format of the version plan and the version branch information does not conform to the standard version information specification, the code hook converts the version plan and / or version branch information that does not conform to the specification based on the format conversion model;
[0109] The code hook extracts the standard version information from the converted version plan and version branch information based on a version information extraction template.
[0110] Furthermore, when the verification result is successful, the code library receives the target code, updates the code stored in the library based on the target code, and generates prompt information indicating successful submission;
[0111] When the verification result is a verification failure, the code library rejects the target code and generates a prompt message indicating submission failure.
[0112] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0113] The above-mentioned device can be implemented in the form of a computer program. Figure 6 Runs on the computer device shown.
[0114] See also Figure 6 , Figure 6 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.
[0115] See also Figure 6 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0116] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any code version verification method based on the code hook.
[0117] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0118] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any code version verification method based on the code hook.
[0119] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0120] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0121] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0122] When receiving the code submission instruction of the target code, the code library obtains the current version parameter of the target code, and sends the current code version number in the current version parameter to the code hook;
[0123] The code hook sends the current code version number to the collaboration platform, and obtains the standard version information corresponding to the target code from the collaboration platform;
[0124] The code hook performs version and / or branch verification on the target code based on the current version parameter and the standard version information to obtain a first verification result, and feeds the first verification result back to the code library;
[0125] The code library processes the code submission instruction based on the first verification result.
[0126] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0127] The code repository sends the branch format in the current version parameter to the code hook;
[0128] The code hook determines the code type of the target code based on the branch format;
[0129] If the code type is a version main branch, the following is performed: the code hook sends the current code version number to the collaboration platform, and receives standard version information fed back by the collaboration platform.
[0130] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0131] If the code type is a personal branch, the code hook generates a verification pass and sends the verification result of the verification pass to the code library.
[0132] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0133] The code library obtains the code submission user information and sends the submission user information to the code hook;
[0134] The code hook sends the current code version number to the collaboration platform, and receives a submitted user whitelist fed back by the collaboration platform;
[0135] The code hook performs submission permission verification on the target code based on the submission user whitelist and the submission user information, obtains a second verification result, and feeds the second verification result back to the code library;
[0136] The code library processes the code submission instruction based on the second verification result.
[0137] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0138] The code hook sends a submission specification acquisition instruction to the collaboration platform, and receives code submission specification information fed back by the collaboration platform;
[0139] The code hook performs submission specification verification on the target code based on the code submission specification information, obtains a third verification result, and feeds the third verification result back to the code library;
[0140] The code library processes the code submission instruction based on the third verification result.
[0141] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0142] The code hook sends the current code version number to the collaboration platform, and receives the version plan and version branch information of the project to which the target code belongs fed back by the collaboration platform;
[0143] The code hook determines the format of the version plan and the version branch information based on the standard version information specification;
[0144] When the format of the version plan and the version branch information does not conform to the standard version information specification, the code hook converts the version plan and / or version branch information that does not conform to the specification based on the format conversion model;
[0145] The code hook extracts the standard version information from the converted version plan and version branch information based on a version information extraction template.
[0146] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0147] When the verification result is successful, the code library receives the target code, updates the code stored in the library based on the target code, and generates prompt information indicating successful submission;
[0148] When the verification result is a verification failure, the code library rejects the target code and generates a prompt message indicating submission failure.
[0149] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Medi a Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card), etc., equipped on the computer device.
[0150] The above is only a specific implementation 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 various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A code version verification method based on code hook, characterized in that: The code version verification method is applied to a code version verification system, the code version verification system includes a code library, a code hook and a collaboration platform, and the code version verification method includes the following steps: When receiving the code submission instruction of the target code, the code library obtains the current version parameter of the target code, and sends the current code version number in the current version parameter to the code hook; The code hook sends the current code version number to the collaboration platform, and obtains the standard version information corresponding to the target code from the collaboration platform; The code hook performs version and / or branch verification on the target code based on the current version parameter and the standard version information to obtain a first verification result, and feeds the first verification result back to the code library; The code library processes the code submission instruction based on the first verification result.
2. The code version verification method based on code hook according to claim 1, characterized in that: Before the code hook sends the current code version number to the collaboration platform and obtains the standard version information corresponding to the target code from the collaboration platform, it also includes: The code repository sends the branch format in the current version parameter to the code hook; The code hook determines the code type of the target code based on the branch format; If the code type is a version main branch, the following is performed: the code hook sends the current code version number to the collaboration platform, and receives standard version information fed back by the collaboration platform.
3. The code version verification method based on code hook according to claim 2, characterized in that: After the code hook determines the code type of the target code based on the branch format, the code hook further includes: If the code type is a personal branch, the code hook generates a verification pass and sends the verification result of the verification pass to the code library.
4. The code version verification method based on code hook according to claim 1, characterized in that: The code version verification method also includes: The code library obtains the code submission user information and sends the submission user information to the code hook; The code hook sends the current code version number to the collaboration platform, and receives a submitted user whitelist fed back by the collaboration platform; The code hook performs submission permission verification on the target code based on the submission user whitelist and the submission user information, obtains a second verification result, and feeds the second verification result back to the code library; The code library processes the code submission instruction based on the second verification result.
5. The code version verification method based on code hook according to claim 1, characterized in that: The code hook performs version and / or branch verification on the target code based on the current version parameter and the standard version information, and feeds back the verification result to the code library, and further includes: The code hook sends a submission specification acquisition instruction to the collaboration platform, and receives code submission specification information fed back by the collaboration platform; The code hook performs submission specification verification on the target code based on the code submission specification information, obtains a third verification result, and feeds the third verification result back to the code library; The code library processes the code submission instruction based on the third verification result.
6. The code version verification method based on code hook according to claim 1, characterized in that: The code hook sends the current code version number to the collaboration platform, and obtains the standard version information corresponding to the target code from the collaboration platform, including: The code hook sends the current code version number to the collaboration platform, and receives the version plan and version branch information of the project to which the target code belongs fed back by the collaboration platform; The code hook determines the format of the version plan and the version branch information based on the standard version information specification; When the format of the version plan and the version branch information does not conform to the standard version information specification, the code hook converts the version plan and / or version branch information that does not conform to the specification based on the format conversion model; The code hook extracts the standard version information from the converted version plan and version branch information based on a version information extraction template.
7. The code version verification method based on code hook according to any one of claims 1 to 6, characterized in that: The code library processes the code submission instruction based on the verification result, specifically including: When the verification result is successful, the code library receives the target code, updates the code stored in the library based on the target code, and generates prompt information indicating successful submission; When the verification result is a verification failure, the code library rejects the target code and generates a prompt message indicating submission failure.
8. A code version verification system, characterized in that: The code version verification system comprises: The code library is used to obtain the current version parameters of the target code when receiving the code submission instruction of the target code, and send the current code version number in the current version parameters to the code hook; A code hook, used to send the current code version number to the collaboration platform, and obtain the standard version information corresponding to the target code from the collaboration platform; A collaboration platform, used for the code hook to perform version and / or branch verification on the target code based on the current version parameter and the standard version information, obtain a first verification result, and feed the first verification result back to the code library; The code library is further used to process the code submission instruction based on the first verification result.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a code version verification program based on a code hook stored in the memory and executable by the processor, wherein when the code version verification program based on a code hook is executed by the processor, the steps of the code version verification method based on a code hook as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a code version verification program based on a code hook, wherein when the code version verification program based on a code hook is executed by a processor, the steps of the code version verification method based on a code hook as described in any one of claims 1 to 7 are implemented.