Code management method and device, electronic equipment and computer readable storage medium
By deploying Git Hooks on both the client and server sides of the GitLab platform, the entire code submission process is checked for compliance and security, which solves the problem of insufficient code management standards, improves code quality and security, and reduces maintenance costs.
Patent Information
- Application Number
- CN202511300517.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-12
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-09-12
AI Technical Summary
The existing GitLab platform lacks effective control over code submissions, resulting in inconsistent code standards, chaotic branch management, and disorganized code logic, which affects code quality and maintainability. Furthermore, the lack of standardized requirements for submission information leads to difficulties in version rollback and security risks.
By deploying Git Hooks on both the client and server sides, code upload data is checked for compliance, including commit information, branch information, and code content, to ensure that it conforms to preset data. Static code analysis tools are used for syntax checking and security vulnerability scanning, and AI resources are combined for code review, thereby achieving automated and intelligent code management.
It raised the bar for code quality, standardized team collaboration practices, reduced long-term code maintenance costs, ensured the standardization and security of code submissions, and improved the efficiency and security of code management.
Smart Images

Figure CN120821491B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and particularly relates to a code management method and device, electronic equipment and computer readable storage medium. BACKGROUND
[0002] With the continuous expansion of software scale and the increasing number of development teams, the code version control tool Git has become an indispensable tool in the software development process. GitLab, as a code hosting platform based on Git, provides code hosting, version control, code review and other functions, and is widely used in software development teams. However, the existing GitLab platform lacks effective management and control of code submission, resulting in many problems.
[0003] Developers lack effective constraints when submitting code, resulting in problems such as inconsistent code specifications, chaotic branch management, and chaotic code logic, affecting code quality and maintainability. Lack of specification requirements for submission information may result in unclear submission information description, version rollback difficulties, and other problems, affecting the efficiency of code version management. Some contents in the code that are prone to memory leaks or attacks and sensitive information may be included, and lack of effective detection mechanism may lead to sensitive information leakage, causing security risks. SUMMARY
[0004] Therefore, the embodiments of the present disclosure provide a code management method and device, electronic equipment and computer readable storage medium to solve the problem of lack of effective management and control in the code submission process in the prior art.
[0005] In a first aspect, the present disclosure provides a central processing unit code management method, the method comprising: receiving code upload data submitted or pushed by a user, the code upload data comprising code change information, submission information and branch information; performing first specification checking on the code upload data through a client-side Git Hook, the first specification checking comprising checking whether the submission type, scope and topic field of the submission information are consistent with preset data; if the first specification checking is passed, sending the code upload data to a server side, and if not, terminating the operation and returning first prompt information to the user; after sending the code upload data to the server side, receiving second prompt information or storage success information returned by the server side, wherein the second prompt information and the storage success information are generated by the server side after performing second specification checking on the code upload data through a server-side Git Hook.
[0006] In a second aspect, the disclosure provides a code management method, which comprises: receiving code upload data sent by a client, wherein the code upload data is sent by the client when the code upload data passes a first specification check by a client Git Hook, and the code upload data comprises code change information, commit information and branch information; performing a second specification check on the user information and the code upload data by a server-side Git Hook, wherein the second specification check comprises checking whether the commit type, scope and subject field of the commit information are consistent with preset data, and checking whether the author information in the commit information belongs to a legal user account; if the second specification check passes, completing code storage according to the code upload data and returning storage success information to the client, and if the second specification check fails, rejecting a direct push operation and returning second prompt information to the client.
[0007] In a third aspect, the disclosure provides a code management device, which comprises: a first receiving module configured to receive code upload data submitted or pushed by a user, wherein the code upload data comprises code change information, commit information and branch information; a first checking module configured to perform a first specification check on the code upload data by a client Git Hook, wherein the first specification check comprises checking whether the commit type, scope and subject field of the commit information are consistent with preset data; an upload module configured to send the code upload data to a server-side when the first specification check passes, and terminate the operation and return first prompt information to the user when the first specification check fails; and a second receiving module configured to receive second prompt information or storage success information returned by the server-side after the code upload data is sent to the server-side, wherein the second prompt information and the storage success information are generated by the server-side after performing a second specification check on the code upload data by a server-side Git Hook.
[0008] In a fourth aspect, the disclosure provides a code management device, which comprises: a third receiving module configured to receive code upload data sent by a client, wherein the code upload data is sent by the client when the code upload data passes a first specification check by a client Git Hook, and the code upload data comprises code change information, commit information and branch information; a second checking module configured to perform a second specification check on the user information and the code upload data by a server-side Git Hook, wherein the second specification check comprises checking whether the commit type, scope and subject field of the commit information are consistent with preset data, and checking whether the author information in the commit information belongs to a legal user account; and a storage module configured to complete code storage according to the code upload data and return storage success information to the client when the second specification check passes, and reject a direct push operation and return second prompt information to the client when the second specification check fails.
[0009] In a third aspect, the present disclosure provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0010] In a fourth aspect, the present disclosure provides a readable storage medium, which stores a computer program, wherein the computer program implements the steps of the above method when executed by a processor.
[0011] Compared with the prior art, the present disclosure has the beneficial effects that: by performing different audits on the submitted code on the client and the server respectively, the problem of insufficient code management and standard measures of Gitlab on the submitted code is solved, the code quality threshold is improved, and the long-term maintenance cost of the company code is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor.
[0013] Figure 1 is a scene schematic diagram of an application scenario of the present disclosure;
[0014] Figure 2 is a flow schematic diagram of a code management method provided by the present disclosure;
[0015] Figure 3 is a flow schematic diagram of another code management method provided by the present disclosure;
[0016] Figure 4 is a structural schematic diagram of a code management device provided by the present disclosure;
[0017] Figure 5 is a structural schematic diagram of another code management device provided by the present disclosure;
[0018] Figure 6 is a structural schematic diagram of an electronic device provided by the present disclosure. DETAILED DESCRIPTION
[0019] In the following description, for the purposes of explanation, numerous specific details are set forth in order to thoroughly describe an embodiment according to the present disclosure. It should be understood, however, that the embodiments according to the present disclosure can be practiced in other embodiments that do not include all the specific details described. In other instances, well-known structures and devices are shown in block diagram form.
[0020] The code management method and apparatus according to embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0021] Figure 1 FIG. 1 is a schematic diagram of an application scenario of an embodiment of the present disclosure. The application scenario can include terminal devices 101, 102, and 103, a server 104, and a network 105.
[0022] The terminal devices 101, 102, and 103 can be hardware or software. When the terminal devices 101, 102, and 103 are hardware, they can be various electronic devices with a display screen and supporting communication with the server 104, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, and the like; when the terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices as above. The terminal devices 101, 102, and 103 can be implemented as a plurality of software or software modules, or as a single software or software module, and the embodiments of the present disclosure do not limit this. Further, the terminal devices 101, 102, and 103 can have various applications installed thereon, such as a data processing application, an instant messaging tool, a social platform software, a search application, a shopping application, and the like.
[0023] The server 104 can be a server that provides various services, for example, a background server that receives a request sent by a terminal device that establishes a communication connection therewith. The background server can receive and analyze the request sent by the terminal device, and generate a processing result. The server 104 can be a single server, a server cluster composed of a plurality of servers, or a cloud computing service center, and the embodiments of the present disclosure do not limit this.
[0024] It should be noted that the server 104 can be hardware or software. When the server 104 is hardware, it can be various electronic devices that provide various services for the terminal devices 101, 102, and 103. When the server 104 is software, it can be a plurality of software or software modules that provide various services for the terminal devices 101, 102, and 103, or a single software or software module that provides various services for the terminal devices 101, 102, and 103, and the embodiments of the present disclosure do not limit this.
[0025] The network 105 can be a wired network using coaxial cables, twisted-pair cables and optical fibers, or a wireless network that can realize interconnection of various communication devices without wiring, for example, Bluetooth, Near Field Communication (NFC), Infrared, etc., and the present disclosure does not limit the same.
[0026] The user can establish a communication connection with the server 104 via the network 105 through the terminal devices 101, 102 and 103 to receive or send information, etc.
[0027] It should be noted that the specific types, numbers and combinations of the terminal devices 101, 102 and 103, the server 104 and the network 105 can be adjusted according to the actual needs of the application scenario, and the present disclosure does not limit the same.
[0028] Figure 2 is a flowchart of a code management method provided by an embodiment of the present disclosure. The method provided by the present disclosure can be executed by any electronic device with computer processing capability, and the technical solution of the present disclosure is applied to a client.
[0029] As shown in Figure 2 , the code management method of the client of the present disclosure includes:
[0030] Step S201, receiving the submitted or pushed code upload data of the user, the code upload data including code change information, submission information and branch information.
[0031] Step S202, performing first specification checking on the code upload data through the client Git Hooks (hook), and the first specification checking includes checking whether the submission type, scope and theme field of the submission information are consistent with the preset data.
[0032] Step S203, if the first specification checking is passed, sending the code upload data to the server end, and if not, terminating the operation and returning the first prompt information to the user.
[0033] Step S204, after sending the code upload data to the server end, receiving the second prompt information or the storage success information returned by the server end, wherein the second prompt information and the storage success information are generated by the server end after performing second specification checking on the code upload data through the server end Git Hooks.
[0034] Specifically, the first specification checking further includes calling an external static code analysis tool to perform syntax checking and static security vulnerability scanning on the code meeting the set requirements.
[0035] The technical scheme of the embodiment of the present disclosure provides an automatic quality control system integrated in a Git code management process. The system performs GitHooks on the client side and the server side, and performs mandatory or guiding specification inspection on the submission information, branch strategy and code content in the whole code submission process. The scheme fundamentally improves the entry quality of the code base, unifies the team collaboration specification, and significantly reduces the long-term maintenance cost of the code.
[0036] Steps S201, S202 and S203 are steps of checking information in the code submission process by the client. In steps S201, S202 and S203, Client-Side Hooks are used to perform instant inspection before the developer submits the code to the local repository. The purpose is to find and fix problems as early as possible, solve most of the specification problems in the local development stage, avoid unqualified code into the public process, and improve the personal efficiency of the developer.
[0037] Specifically, when the developer performs operations such as git commit or git push locally, the Client-Side Hooks are triggered. The hook script is pre-installed in the.git / Hooks / directory of the local repository or other directories with the same effect.
[0038] The client calls an external static code analysis tool to perform syntax checking and basic vulnerability / bad smell scanning on specific language files. The submission information format is checked to check whether the submission information format conforms to the agreed format. The branch naming is checked to check whether the function branch naming conforms to the specification.
[0039] When the client passes the check, the operation continues, and the code is submitted or ready to be pushed. When the check fails, the operation can be aborted, and explicit and operable error information is output to guide the developer how to modify. The operation can also continue, but a prompt information is given. The latter is mainly applicable to non-mandatory rules.
[0040] Figure 3 is a flowchart of another code management method provided by the embodiment of the present disclosure. The method provided by the embodiment of the present disclosure can be executed by any electronic device with computer processing capability, and the technical scheme of the embodiment of the present disclosure is applied to the server side.
[0041] As shown in Figure 3 , the code management method of the server side of the embodiment of the present disclosure includes:
[0042] In step S301, the code upload data sent by the client is received, wherein the code upload data is sent by the client when the code upload data is checked by the client Git Hooks and the checking is passed, and the code upload data includes code change information, commit information and branch information.
[0043] In step S302, the user information and the code upload data are checked by the server-side Git Hooks for the second specification, and the second specification includes checking whether the commit type, scope and subject field of the commit information are consistent with the preset data, and checking whether the author information in the commit information belongs to a legal user account.
[0044] In step S303, if the second specification is passed, the code is completed into the library according to the code upload data and the library success information is returned to the client, and if it is not passed, the direct push operation is rejected and the second prompt information is returned to the client.
[0045] Specifically, the second specification further includes checking whether the target branch of the branch information is a branch in the pre-defined protected branch list, and if so, the direct push operation is rejected.
[0046] Specifically, the second specification further includes calling an external static code analysis tool to perform syntax checking and static security vulnerability scanning on the code meeting the set requirements.
[0047] Specifically, before receiving the code upload data sent by the client, the code management method of the embodiment of the disclosure further includes automatically distributing, installing and updating the hook script and script configuration of the client to a plurality of clients.
[0048] Steps S302 and S303 are steps of checking information in the code commit process by the server side. In steps S302 and S303, Server-Side Hooks are used to perform final consistency checking on the information in the code commit process before the code is pushed to the remote central repository, to ensure that all the codes in the library meet the team's established specifications, especially suitable for scenarios such as enforcing protected branch strategy and verifying whether the client hook is bypassed. Among them, in the platform such as GitLab, the information in the code commit process is checked by the server-side hook for final consistency.
[0049] Specifically, when the client performs the git push operation, the code reaches the GitLab server, and the Server-Side Hooks are triggered. Among them, the hook script is pre-deployed in the specific repository or globally of the GitLab server.
[0050] When the server side checks whether the submission type, scope and subject field of the submission information are consistent with the preset data, it needs to verify whether the submission author information is valid and matches the GitLab account to prevent forgery. When the server side performs submission information specification strengthening check, it needs to check the submission information format again to ensure that the client check is not bypassed. When the server side performs code change content check, it can perform deeper code specification or compliance check than the client detection. The server side adopts branch protection strategy to perform code change content check, strictly prohibits direct pushing to protected branches, and forcibly requires to use merge request to ensure the normalization of code submission.
[0051] When the server side passes the check, the push is successful, and the code is stored in the repository. When the check fails, the entire push is rejected, and detailed error information is returned to the client. The developer must fix it locally according to the prompt before re-pushing.
[0052] According to the code management method of the embodiment of the present disclosure, by performing different audits on the submitted code on the client side and the server side respectively, the problem of insufficient code submission management specification of Gitlab is solved, the code quality threshold is improved, and the long-term maintenance cost of company code is reduced.
[0053] Specifically, the technical scheme of the embodiment of the present disclosure can generate a submission history with high readability and easy to automatically generate change log, and unify the submission information format; can clearly define branch naming, creation and merging rules, protect key branches, realize the standardization of Git workflow, and unify the branch management model; by using static code analysis, syntax errors, potential faults and security vulnerabilities can be automatically captured in the submission stage, and the quality assurance is improved. In addition, code review can be combined with application Gitlab runner and AI (Artificial Intelligence, Artificial Intelligence) resources to improve the intelligent level of the code management scheme.
[0054] The technical scheme of the embodiment of the present disclosure can change the code specification and quality standard into a hard requirement that can be enforced through automated code checking. Through account verification, the authenticity and traceability of the code submission author can be ensured to meet the audit requirements. And complex functions can be realized by calling external scripts and tools, which reserves space for future integration of AI code review, so as to continuously improve the automation and intelligence level. In addition, the automatic operation and maintenance tool Ansible can be used to realize the unified deployment and update of the client, and the design concept and implementation of Git Hooks can be adapted to any Git-based platform.
[0055] The code management platform is mainly used for code management of the internal software development environment of a company, and can also be used for other development environments based on Gitlab. The system partially solves the problem of insufficient code management specification measures on Gitlab, improves the code quality threshold through unified submission specifications, and reduces the long-term maintenance cost of company code. Moreover, the system supports subsequent expansion of more detailed and differentiated rule restrictions, thereby raising the code ability and specification degree of developers.
[0056] The code management platform is mainly used for code management of the internal software development environment of a company, and can also be used for other development environments based on Gitlab. The system partially solves the problem of insufficient code management specification measures on Gitlab, improves the code quality threshold through unified submission specifications, and reduces the long-term maintenance cost of company code. Moreover, the system supports subsequent expansion of more detailed and differentiated rule restrictions, thereby raising the code ability and specification degree of developers.
[0057] All Git-based code management and integrated deployment environments, including but not limited to Gitlab, Github, Gitee and Gerrit, support basic Git operations and Git Hooks applications. The platform of the present scheme also uses Git Hooks as the entry point of basic functions.
[0058] The functions that are not supported or not easy to implement by Git Hooks can be realized by installing and configuring other plugins in the manner of being called by GitHooks.
[0059] When a user writes a stage of code on the platform and then submits, the Server-Side Hooks of the pre-deployed Git Hooks will take effect, check the user's changes, and check the user's submission. If it does not conform to the specification, it will give a prompt information of prohibition or warning according to the conflict place, and the user will submit again after solving these information. If there is no non-compliance place, it will be directly submitted to the Gitlab Server end. After the Server end receives the submission, the Hooks of the Server end will take effect, and will check the user's submission information, branch information, code change content, etc., and make corresponding processing according to the checked information.
[0060] On the server side, the common commit-related Hooks are often encountered, that is, Hooks with commit, but the Hooks for rebase, merge and apply-patch are less used, and in the case of commit specification, the Hooks of other scenarios have a standard basis. In addition, it is possible that the client's Git Hooks user does not perform, so it needs to be checked on the server side. The checks that can be uniformly performed on the server side include checking account information, checking commit specification information, checking target branch information, especially related to protected branches, and simple file syntax analysis.
[0061] Since the client's Git Hooks cannot be directly inherited when downloading and synchronizing the code, it needs to be manually set by each user. However, this work is not very intuitive and understandable for most developers, so the source code of the Client Hooks needs to be provided for installation and deployment guidance on the system, and for the Linux environment provided by the company, uniform deployment is performed to directly integrate Git Hooks.
[0062] In the basic scheme of using Ansible for centralized deployment of Git Hooks, a Control (control) node stores the deployment source code and Ansible program of Ansible, and a list of target devices, and then establishes a password-free connection channel with each target device through SSH (Secure Shell, Secure Shell protocol) to directly issue deployment instructions on the Control node to the target device for execution. This can ensure the consistency of the environment of the target device.
[0063] As shown in Figure 4 The code management apparatus provided by the present disclosure is applied to a client and includes:
[0064] The first receiving module 401 is configured to receive code upload data submitted or pushed by a user, the code upload data including code change information, submission information and branch information;
[0065] The first checking module 402 is configured to perform a first specification check on the code upload data through a client Git Hook, the first specification check including checking whether the submission type, scope and topic field of the submission information are consistent with preset data;
[0066] The uploading module 403 is configured to send the code upload data to a server side when the first specification check is passed, and terminate the operation and return a first prompt information to the user when the first specification check is not passed;
[0067] The second receiving module 404 is configured to receive second prompt information or warehousing success information returned by the server side after the code uploading data is sent to the server side, wherein the second prompt information and the warehousing success information are generated by the server side after the code uploading data is subjected to the second specification check by the server side Git Hooks.
[0068] As shown in Figure 5 The code management apparatus provided by the present disclosure is applied to a server side, and comprises:
[0069] The third receiving module 501 is configured to receive code uploading data sent by the client, wherein the code uploading data is sent when the code uploading data is subjected to the first specification check by the client Git Hooks and the check is passed, and the code uploading data comprises code change information, commit information and branch information.
[0070] The second checking module 502 is configured to perform the second specification check on the user information and the code uploading data by the server side Git Hooks, and the second specification check comprises checking whether the commit type, the scope and the subject field of the commit information are consistent with preset data, and checking whether the author information in the commit information belongs to a legal user account.
[0071] The warehousing module 503 is configured to complete code warehousing according to the code uploading data and return warehousing success information to the client when the second specification check is passed, and reject the direct push operation and return second prompt information to the client when the second specification check is not passed.
[0072] Since the various functional modules of the code management apparatus of the example embodiments of the present disclosure correspond to the steps of the example embodiments of the code management method described above, for details not disclosed in the apparatus embodiments of the present disclosure, please refer to the code management method embodiments of the present disclosure described above.
[0073] The code management apparatus according to the example embodiments of the present disclosure solves the problem of insufficient code management specification measures of Gitlab by performing different audits on the submitted code at the client side and the server side, improves the code quality threshold, and reduces the long-term maintenance cost of the company code.
[0074] Figure 6 is a schematic diagram of an electronic device 6 provided by an example embodiment of the present disclosure. As shown in Figure 6 The electronic device 6 of this embodiment comprises a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable on the processor 601. The processor 601 implements the steps in the above-mentioned various method embodiments when executing the computer program 603. Alternatively, the processor 601 implements the functions of the modules in the above-mentioned various apparatus embodiments when executing the computer program 603.
[0075] The electronic device 6 can be a desktop computer, a notebook computer, a palm computer, a cloud server, and the like. The electronic device 6 can include, but is not limited to, a processor 601 and a memory 602. Those skilled in the art can understand that the processor 601 and the memory 602 can be divided into different functional units or modules according to the actual needs, and the functions of the processor 601 and the memory 602 can be combined into one processing unit, or two or more units can be integrated into one unit. Figure 6 The electronic device 6 is only an example and does not constitute a limitation on the electronic device 6, and can include more or fewer components or different components than those shown.
[0076] The processor 601 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
[0077] The memory 602 can be an internal storage unit of the electronic device 6, for example, a hard disk or a memory of the electronic device 6. The memory 602 can also be an external storage device of the electronic device 6, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 6. The memory 602 can also include both the internal storage unit and the external storage device of the electronic device 6. The memory 602 is used to store computer programs and other programs and data required by the electronic device.
[0078] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional units and modules is exemplified, and in actual application, the above functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0079] If the integrated module is implemented in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by instructing related hardware through a computer program, and the computer program can be stored in a computer readable storage medium. When the processor executes the computer program, the steps of the above-mentioned various method embodiments can be implemented. The computer program can include computer program code, which can be in the form of source code, object code, executable file or some intermediate form, etc. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electric carrier wave signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electric carrier wave signal and telecommunication signal.
[0080] The above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than limit them; although the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure.
Claims
1. A code management method characterized by, The method comprises: receiving user's submitted or pushed code upload data, the code upload data comprising code change information, commit information and branch information; performing first specification check on the code upload data by client Git Hooks, the first specification check comprising checking whether the commit type, scope and subject field of the commit information are consistent with preset data; if the first specification check passes, sending the code upload data to the server side, and if not, terminating the operation and returning first prompt information to the user; after sending the code upload data to the server side, receiving the second prompt information or the storage success information returned by the server side, wherein the second prompt information and the storage success information are generated by the server side after performing second specification check on the code upload data by server Git Hooks, the second specification check comprising checking whether the commit type, scope and subject field of the commit information are consistent with preset data, and checking whether the author information in the commit information belongs to a legal user account, if the second specification check passes, completing code storage according to the code upload data and returning storage success information to the client, and if not, rejecting direct push operation and returning second prompt information to the client.
2. The method of claim 1, wherein, The first specification check further comprises calling external static code analysis tools to perform syntax check and static security vulnerability scanning on the code meeting the set requirements.
3. A code management method characterized by, The method comprises: receiving code upload data sent by the client, wherein the code upload data is sent when the first specification check on the code upload data by the client Git Hooks passes, the code upload data comprising code change information, commit information and branch information, and the first specification check comprising checking whether the commit type, scope and subject field of the commit information are consistent with preset data; performing second specification check on the user information and the code upload data by server Git Hooks, the second specification check comprising checking whether the commit type, scope and subject field of the commit information are consistent with preset data, and checking whether the author information in the commit information belongs to a legal user account; if the second specification check passes, completing code storage according to the code upload data and returning storage success information to the client, and if not, rejecting direct push operation and returning second prompt information to the client.
4. The method of claim 3, wherein, The second specification check further comprises checking whether the target branch of the branch information is a branch in a predefined protected branch list, and if so, rejecting direct push operation.
5. The method of claim 3, wherein, The second specification check further comprises calling external static code analysis tools to perform syntax check and static security vulnerability scanning on the code meeting the set requirements.
6. The method of claim 3, wherein, Before receiving the code upload data sent by the client, the method further comprises automatically distributing, installing and updating the hook scripts and script configurations of the client to a plurality of clients.
7. A code management apparatus characterized by comprising: The device comprises: A first receiving module for receiving user's submitted or pushed code upload data, the code upload data comprising code change information, submission information and branch information; A first checking module for performing first specification checking on the code upload data by client-side Git Hooks, the first specification checking comprising checking whether the submission type, scope and topic fields of the submission information are consistent with preset data; An upload module for sending the code upload data to the server side when the first specification checking is passed, and terminating operation and returning first prompt information to the user when the first specification checking is not passed; A second receiving module for receiving second prompt information or storage success information returned by the server side after the code upload data is sent to the server side, wherein the second prompt information and the storage success information are generated by the server side after performing second specification checking on the code upload data by server-side Git Hooks, the second specification checking comprising checking whether the submission type, scope and topic fields of the submission information are consistent with preset data, and checking whether the author information in the submission information belongs to a legal user account, if the second specification checking is passed, completing code storage according to the code upload data and returning storage success information to the client, if the second specification checking is not passed, rejecting direct push operation and returning second prompt information to the client.
8. A code management apparatus characterized by comprising: The device comprises: A third receiving module for receiving code upload data sent by a client, wherein the code upload data is sent when the client-side Git Hooks performs first specification checking on the code upload data and the checking is passed, the code upload data comprising code change information, submission information and branch information, and the first specification checking comprising checking whether the submission type, scope and topic fields of the submission information are consistent with preset data; A second checking module for performing second specification checking on user information and the code upload data by server-side Git Hooks, the second specification checking comprising checking whether the submission type, scope and topic fields of the submission information are consistent with preset data, and checking whether the author information in the submission information belongs to a legal user account; A storage module for completing code storage according to the code upload data and returning storage success information to the client when the second specification checking is passed, and rejecting direct push operation and returning second prompt information to the client when the second specification checking is not passed.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the steps of the method of any one of claims 1 to 6.
10. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 9. The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 6.
Citation Information
Patent Citations
Code submission log processing method and device
CN114327588A
Systems and methods for utilizing webhooks integrated in paas supported application development and deployment
US20180275966A1