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 problem of lack of effective control during code submission was solved, resulting in improved code quality, enhanced security, and reduced code maintenance costs.
Patent Information
- Application Number
- CN202511300517.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-12
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-09-12
Smart Images

Figure CN120821491A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a code management method, device, electronic device, and computer-readable storage medium. Background Art
[0002] With the continuous expansion of software development and the increasing number of development teams, the code version control tool Git has become an indispensable tool in the software development process. GitLab, a Git-based code hosting platform, provides code hosting, version control, and code review features, and is widely used by software development teams. However, the existing GitLab platform lacks effective control over code submissions, leading to numerous issues.
[0003] The lack of effective constraints on developers submitting code leads to inconsistent code standards, chaotic branch management, and confusing code logic, impacting code quality and maintainability. A lack of standardized requirements for submission information can lead to unclear submission information and difficulty in rolling back versions, hindering the efficiency of code version management. Code may contain content that is susceptible to memory leaks, vulnerable to attacks, and sensitive information. The lack of effective detection mechanisms can lead to the leakage of sensitive information, posing a security risk. Summary of the Invention
[0004] In view of this, the embodiments of the present disclosure provide a code management method, device, electronic device, 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 of an embodiment of the present disclosure, a method for managing central processing unit code is provided, the method comprising: receiving code upload data submitted or pushed by a user, the code upload data comprising code change information, commit information and branch information; performing a first compliance check on the code upload data through client-side Git Hooks, the first compliance check comprising checking whether the submission type, scope and subject fields of the submission information are consistent with preset data; if the first compliance check passes, sending the code upload data to a server side, and if not, terminating the operation and returning a first prompt message to the user; after sending the code upload data to the server side, receiving a second prompt message or storage success message returned by the server side, wherein the second prompt message and storage success message are generated by the server side after performing a second compliance check on the code upload data through server-side Git Hooks.
[0006] A second aspect of an embodiment of the present disclosure provides a code management method, the method comprising: receiving code upload data sent by a client, wherein the code upload data is sent when the client performs a first compliance check on the code upload data through client-side Git Hooks and the check passes, the code upload data including code change information, commit information and branch information; performing a second compliance check on user information and code upload data through server-side Git Hooks, the second compliance check including checking whether the submission type, scope and subject fields of the submission information are consistent with preset data, and checking whether the author information in the submission information belongs to a legitimate user account; if the second compliance check passes, completing the code storage according to the code upload data and returning a successful storage information to the client; if it fails, rejecting the direct push operation and returning a second prompt information to the client.
[0007] According to a third aspect of an embodiment of the present disclosure, a code management device is provided, comprising: a first receiving module for receiving code upload data submitted or pushed by a user, the code upload data comprising code change information, commit information and branch information; a first checking module for performing a first compliance check on the code upload data through client-side Git Hooks, the first compliance check comprising checking whether the submission type, scope and subject fields of the submission information are consistent with preset data; an uploading module for sending the code upload data to a server side when the first compliance check passes, and terminating the operation and returning a first prompt message to the user when the check fails; a second receiving module for receiving a second prompt message or successful storage information returned by the server side after sending the code upload data to the server side, wherein the second prompt message and successful storage information are generated by the server side after performing a second compliance check on the code upload data through server-side Git Hooks.
[0008] In a fourth aspect of an embodiment of the present disclosure, a code management device is provided, the device comprising: a third receiving module, receiving code upload data sent by a client, wherein the code upload data is sent when the client performs a first compliance check on the code upload data through client-side Git Hooks and the check passes, and the code upload data includes code change information, commit information and branch information; a second checking module, performing a second compliance check on user information and code upload data through server-side Git Hooks, the second compliance check including checking whether the submission type, scope and subject fields of the submission information are consistent with preset data, and checking whether the author information in the submission information belongs to a legitimate user account; a warehousing module, for completing code warehousing according to the code upload data and returning a successful warehousing information to the client when the second compliance check passes, and refusing a direct push operation and returning a second prompt information to the client when the check fails.
[0009] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0010] According to a fourth aspect of the embodiments of the present disclosure, a readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the above method are implemented.
[0011] Compared with the prior art, the disclosed embodiments have the following advantages: by performing different reviews on the submitted code on the client and server sides respectively, the problem of insufficient standard measures for Gitlab's management of submitted code is solved, the code quality threshold is improved, and the cost of long-term maintenance of the company's code is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0013] Figure 1 is a schematic diagram of an application scenario of an embodiment of the present disclosure; Figure 2 This is a flowchart of a code management method provided by an embodiment of the present disclosure; Figure 3 is a flowchart of another code management method provided by an embodiment of the present disclosure; Figure 4 This is a schematic diagram of the structure of a code management device provided by an embodiment of the present disclosure; Figure 5 is a structural diagram of another code management device provided by an embodiment of the present disclosure; Figure 6 It is a structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0014] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present disclosure. However, it will be apparent to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present disclosure with unnecessary detail.
[0015] The code management method and apparatus according to the embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0016] Figure 1 10 is a schematic diagram of an application scenario of an embodiment of the present disclosure. The application scenario may include terminal devices 101, 102 and 103, a server 104 and a network 105.
[0017] 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 display screens that support communication with the server 104, including but not limited to smartphones, tablet computers, laptop computers, and desktop computers; when the terminal devices 101, 102, and 103 are software, they can be installed in the above electronic devices. The terminal devices 101, 102, and 103 can be implemented as multiple software or software modules, or as a single software or software module, and the embodiments of the present disclosure are not limited to this. Furthermore, various applications can be installed on the terminal devices 101, 102, and 103, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0018] Server 104 may be a server that provides various services, such as a backend server that receives requests sent by terminal devices that establish communication connections with it. The backend server may receive and analyze the requests sent by the terminal devices, and generate processing results. Server 104 may be a single server, a server cluster consisting of multiple servers, or a cloud computing service center, all of which are not limited in the present disclosure.
[0019] It should be noted that the server 104 can be either hardware or software. When the server 104 is hardware, it can be various electronic devices that provide various services to the terminal devices 101, 102, and 103. When the server 104 is software, it can be multiple software programs or software modules that provide various services to the terminal devices 101, 102, and 103, or it can be a single software program or software module that provides various services to the terminal devices 101, 102, and 103. This is not limited in the present embodiment.
[0020] The network 105 may be a wired network connected by coaxial cables, twisted pairs, and optical fibers, or a wireless network that can interconnect various communication devices without wiring, such as Bluetooth, Near Field Communication (NFC), infrared, etc., and the embodiments of the present disclosure do not impose any restrictions on this.
[0021] Users 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.
[0022] It should be noted that the specific types, quantities 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 embodiments of the present disclosure do not limit this.
[0023] Figure 2 The method provided by the embodiment of the present disclosure can be executed by any electronic device with computer processing capabilities, and the technical solution of the embodiment of the present disclosure is applied to the client.
[0024] like Figure 2 As shown, the client code management method of the embodiment of the present disclosure includes: Step S201: receiving code upload data submitted or pushed by a user, where the code upload data includes code change information, commit information, and branch information.
[0025] Step S202: Perform a first compliance check on the code upload data through the client Git Hooks. The first compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with the preset data.
[0026] Step S203: If the first compliance check passes, the code upload data is sent to the server; if not, the operation is terminated and the first prompt information is returned to the user.
[0027] Step S204: After sending the code upload data to the server, a second prompt message or storage success message returned by the server is received, wherein the second prompt message and storage success message are generated by the server after performing a second compliance check on the code upload data through the server-side Git Hooks.
[0028] Specifically, the first compliance check also includes calling an external static code analysis tool to perform syntax checking and static security vulnerability scanning on the code that meets the set requirements.
[0029] The technical solution of the disclosed embodiments provides an automated quality control system integrated into the Git code management process. By systematically deploying and executing GitHooks on both the client and server sides, it performs mandatory or guiding regulatory checks on commit information, branching strategies, and code content throughout the entire code submission process. This solution fundamentally improves the entry quality of code repositories, unifies team collaboration standards, and significantly reduces long-term code maintenance costs.
[0030] Steps S201, S202, and S203 are steps where the client checks the information submitted during the code submission process. In these steps, client-side hooks are used to perform immediate checks before developers submit their code to the local repository. This aims to identify and fix issues as early as possible, resolving most regulatory issues during the local development phase, preventing substandard code from entering the public process and improving developer efficiency.
[0031] Specifically, when a developer performs a git commit or git push operation locally, Client-SideHooks is triggered. The hook script is pre-installed in the local repository's .git / Hooks / directory or another directory with equivalent effects.
[0032] The client calls an external static code analysis tool to perform syntax checking and basic vulnerability and bad smell scanning on specific language files. Submit message formatting checks primarily check for compliance with the agreed format. Branch naming checks primarily check for compliance with standard naming conventions for feature branches and other names.
[0033] If the client passes the check, the operation continues, and the code is committed or prepared for push. If the check fails, the operation can be aborted with a clear, actionable error message to guide the developer on how to make changes, or the operation can continue with a prompt. The latter mainly applies to non-mandatory rules.
[0034] Figure 3 The method provided by the embodiment of the present disclosure can be executed by any electronic device with computer processing capabilities, and the technical solution of the embodiment of the present disclosure is applied to the server side.
[0035] like Figure 3 As shown, the server-side code management method of the embodiment of the present disclosure includes: Step S301: Receive code upload data sent by the client, wherein the code upload data is sent when the client performs a first compliance check on the code upload data through the client Git Hooks and the check passes, and the code upload data includes code change information, commit information, and branch information.
[0036] In step S302, a second compliance check is performed on the user information and code upload data through server-side Git Hooks. The second compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with the preset data, and checking whether the author information in the submission information belongs to a valid user account.
[0037] Step S303: If the second compliance check passes, the code is stored in the library according to the code upload data and a successful storage information is returned to the client. If it fails, the direct push operation is rejected and a second prompt information is returned to the client.
[0038] Specifically, the second compliance check further includes checking whether the target branch of the branch information is a branch in a predefined protected branch list. If so, the direct push operation is rejected.
[0039] Specifically, the second compliance check also includes calling an external static code analysis tool to perform syntax checking and static security vulnerability scanning on the code that meets the set requirements.
[0040] Specifically, before receiving the code upload data sent by the client, the code management method of the embodiment of the present disclosure further includes: automatically distributing, installing and updating the client's hook scripts and script configurations to multiple clients.
[0041] Steps S302 and S303 are the steps where the server checks the information during the code submission process. In these steps, server-side hooks are used to perform a final consistency check on the information during the code submission process before the code is pushed to the remote central repository. This ensures that all code entering the repository complies with the team's established specifications. This is particularly useful for scenarios such as enforcing protected branch policies and verifying whether client-side hooks have been bypassed. On platforms like GitLab, server-side hooks perform a final consistency check on the information during the code submission process.
[0042] Specifically, when a client executes a git push operation and the code reaches the GitLab server, Server-SideHooks are triggered. Among them, the hook script is pre-deployed in a specific repository or globally on the GitLab server.
[0043] When the server checks whether the submission type, scope, and subject fields of the commit 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 performs a reinforced check of the submission information specification, it needs to re-verify the submission information format to ensure that the client check has not been bypassed. When the server checks the content of code changes, it can perform a deeper level of code specification or compliance check than the client-side detection. The server uses a branch protection strategy to check the content of code changes. It is strictly forbidden to push directly to protected branches and the use of merge requests is mandatory to ensure the standardization of code submissions.
[0044] If the server passes the check, the push is successful and the code is stored. If the check fails, the entire push is rejected and a detailed error message is returned to the client. The developer must follow the prompts to fix the problem locally before pushing again.
[0045] According to the code management method of the embodiment of the present invention, by performing different reviews on the submitted code on the client and server respectively, the problem of insufficient standard measures for Gitlab to manage submitted code is solved, the code quality threshold is improved, and the cost of long-term maintenance of the company's code is reduced.
[0046] Specifically, the technical solutions of the disclosed embodiments can generate highly readable commit histories that facilitate automated change log generation, unifying the commit information format. They can also clarify branch naming, creation, and merging rules, protect key branches, standardize Git workflows, and unify branch management models. Static code analysis can automatically capture syntax errors, potential faults, and security vulnerabilities during the commit phase, improving quality assurance. Furthermore, code review can be combined with the GitLab runner application and AI (artificial intelligence) resources to enhance the intelligence of code management solutions.
[0047] The technical solution of the disclosed embodiment can turn code specifications and quality standards into enforceable hard requirements through automated code inspection. Through account verification, the authenticity and traceability of the author of the code submission can be ensured to meet audit requirements. In addition, complex functions can be implemented by calling external scripts and tools, leaving room for future integration of AI code review, thereby continuously improving the level of automation and intelligence. In addition, the automated operation and maintenance tool Ansible can be used to achieve unified deployment and updating of clients. Its design concept and implementation method using Git Hooks can be adapted to any Git-based platform.
[0048] The disclosed embodiment provides a code management platform to improve code quality and management efficiency, and reduce the cost of long-term code maintenance. Specifically, the Server-Side Hooks in the pre-deployed Git Hooks check the user's changes. If they do not comply with the specifications, a prohibition or warning prompt message will be given according to the conflict. The user will submit again after resolving these messages; if there are no non-compliances, it will be submitted directly to the Gitlab server. After the server receives the submission, the server-side Hooks will take effect, and will check the user's submission information, branch information, code changes, etc., and perform corresponding processing based on the checked information.
[0049] The code management platform is primarily used for code management within the company's internal software development environment, but can also be used in other GitLab-based development environments. This system partially addresses the issue of insufficient code management standards in GitLab. By implementing unified submission standards, it raises the bar for code quality and reduces the company's long-term code maintenance costs. Furthermore, the system supports the subsequent expansion of more detailed and differentiated rules and restrictions, enhancing developers' coding skills and standardization.
[0050] All Git-based code management and integrated deployment environments, including but not limited to GitLab, Github, Gitee, and Gerrit, support basic Git operations and the use of Git Hooks. This solution's platform also uses Git Hooks as the entry point for basic functionality.
[0051] Functions that are not supported or difficult to implement by Git Hooks itself can be implemented by installing and configuring other plug-ins and calling them through GitHooks.
[0052] When a user writes a stage of code locally and then submits it, the Server-Side Hooks in the pre-deployed Git Hooks will take effect, checking the user's changes and submissions. If it does not meet the specifications, a prohibition or warning prompt will be given based on the conflict. The user will resolve this information and submit again; if there are no non-compliances, it will be submitted directly to the Gitlab Server. After the server receives the submission, the server-side Hooks will take effect, checking the user's submission information, branch information, code changes, etc., and taking appropriate measures based on the information checked.
[0053] On the server side, standard commit-related hooks are commonly encountered, i.e., hooks with commits. However, rebase, merge, and apply-patch hooks have fewer application scenarios, and with commit specifications, hooks for other scenarios have a standardized foundation. Furthermore, client-side Git Hooks may not be executed, necessitating server-side checks. Checks that can be uniformly performed on the server include: checking account information, checking commit specification information, checking target branch information, especially related to protected branches, and simple file modification syntax analysis.
[0054] Because client-side Git Hooks can't be directly inherited when downloading and syncing code, each user must manually configure them. This isn't intuitive for most developers, so we need to provide system-wide installation and deployment guidance for the Client Hooks source code, as well as a unified deployment for the company's Linux environment, allowing for direct integration of Git Hooks.
[0055] In the basic solution for centralized Git Hook deployment using Ansible, a control node stores the Ansible deployment source code and Ansible programs, as well as a list of target devices. After establishing a password-free connection to each target device via SSH (Secure Shell), the control node directly issues deployment commands to the target device for execution. This ensures consistent environment across all target devices.
[0056] like Figure 4 As shown, the code management device provided by the present disclosure is applied to a client, including: The first receiving module 401 is used to receive code upload data submitted or pushed by the user, where the code upload data includes code change information, submission information, and branch information; A first checking module 402 is configured to perform a first compliance check on the code upload data using client Git Hooks. The first compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with preset data. The upload module 403 is configured to send the code upload data to the server if the first compliance check passes, and terminate the operation and return a first prompt message to the user if the first compliance check fails; The second receiving module 404 is used to receive a second prompt message or storage success message returned by the server after the code upload data is sent to the server, wherein the second prompt message and storage success message are generated by the server after the server performs a second compliance check on the code upload data through the server-side Git Hooks.
[0057] like Figure 5 As shown, the code management device provided by the present disclosure is applied to the server side, including: A third receiving module 501 receives code upload data sent by a client, wherein the code upload data is sent when the client performs a first compliance check on the code upload data through client Git Hooks and the check passes, and the code upload data includes code change information, commit information, and branch information; A second checking module 502 performs a second compliance check on the user information and code upload data through server-side Git Hooks. The second compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with preset data, and checking whether the author information in the submission information belongs to a valid user account; The storage module 503 is used to complete the code storage according to the code upload data and return the storage success information to the client when the second compliance check passes, and reject the direct push operation and return the second prompt information to the client when it fails.
[0058] Since the functional modules of the code management device of the exemplary embodiment of the present disclosure correspond to the steps of the exemplary embodiment of the code management method described above, for details not disclosed in the embodiment of the device of the present disclosure, please refer to the embodiment of the code management method described above.
[0059] According to the code management device of the embodiment of the present disclosure, by performing different reviews on the submitted code on the client and server respectively, the problem of insufficient standard measures for Gitlab to manage submitted code is solved, the code quality threshold is improved, and the cost of long-term maintenance of the company's code is reduced.
[0060] Figure 6 FIG. 6 is a schematic diagram of an electronic device 6 provided in an embodiment of the present disclosure. Figure 6 As shown, the electronic device 6 of this embodiment includes: a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable by the processor 601. When the processor 601 executes the computer program 603, the steps of the above-described method embodiments are implemented. Alternatively, when the processor 601 executes the computer program 603, the functions of the modules in the above-described device embodiments are implemented.
[0061] The electronic device 6 may be a desktop computer, a notebook, a PDA, a cloud server or other electronic device. The electronic device 6 may include but is not limited to a processor 601 and a memory 602. It will be understood by those skilled in the art that Figure 6 This is merely an example of the electronic device 6 and does not limit the electronic device 6 . The electronic device 6 may include more or fewer components than shown in the figure, or different components.
[0062] The processor 601 may be a central processing unit (CPU), or 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.
[0063] The memory 602 may be an internal storage unit of the electronic device 6, such as a hard disk or memory of the electronic device 6. The memory 602 may also be an external storage device of the electronic device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. The memory 602 may also include both an internal storage unit of the electronic device 6 and an external storage device. The memory 602 is used to store computer programs and other programs and data required by the electronic device.
[0064] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0065] If the integrated module is implemented as a software functional unit and sold or used as a standalone product, it can be stored in a computer-readable storage medium. Based on this understanding, the present disclosure can implement all or part of the process steps in the above-mentioned method embodiments by using a computer program to instruct the relevant hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program can include computer program code, which can be in source code form, object code form, executable file, or some intermediate form. Computer-readable media can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, removable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunications signals, and software distribution media. It should be noted that the content included in computer-readable media can be appropriately increased or decreased based on the requirements of legislation and patent practice within a jurisdiction. For example, in some jurisdictions, based on legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunications signals.
[0066] The above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present disclosure, and should all be included in the scope of protection of the present disclosure.
Claims
1. A code management method, characterized in that: The method comprises: Receive code upload data submitted or pushed by users, including code change information, submission information, and branch information; Performing a first compliance check on the code upload data through client Git Hooks, wherein the first compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with preset data; If the first compliance check passes, the code upload data is sent to the server; if not, the operation is terminated and a first prompt message is returned to the user; After sending the code upload data to the server, a second prompt message or storage success message returned by the server is received, wherein the second prompt message and the storage success message are generated by the server after performing a second compliance check on the code upload data through server-side Git Hooks.
2. The method according to claim 1, characterized in that The first compliance check also includes calling an external static code analysis tool to perform syntax checking and static security vulnerability scanning on the code that meets the set requirements.
3. A code management method, characterized in that: The method comprises: Receiving code upload data sent by a client, wherein the code upload data is sent when the client performs a first compliance check on the code upload data through client Git Hooks and the check passes, the code upload data including code change information, commit information, and branch information; Performing a second compliance check on the user information and the code upload data through server-side Git Hooks, wherein the second compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with preset data, and checking whether the author information in the submission information belongs to a valid user account; If the second compliance check passes, the code is uploaded into the warehouse according to the code data and a successful warehouse entry message is returned to the client. If it fails, the direct push operation is rejected and a second prompt message is returned to the client.
4. The method according to claim 3, characterized in that The second compliance check further includes checking whether the target branch of the branch information is a branch in a predefined protected branch list, and if so, rejecting the direct push operation.
5. The method according to claim 3, characterized in that The second compliance check also includes calling an external static code analysis tool to perform syntax checking and static security vulnerability scanning on the code that meets the set requirements.
6. The method according to claim 3, characterized in that Before receiving the code upload data sent by the client, the method further includes: automatically distributing, installing and updating the hook scripts and script configurations of the client to multiple clients.
7. A code management device, characterized in that: The device comprises: A first receiving module is configured to receive code upload data submitted or pushed by a user, wherein the code upload data includes code change information, submission information, and branch information; A first checking module is configured to perform a first compliance check on the code upload data through client Git Hooks, wherein the first compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with preset data; An upload module, configured to send the code upload data to a server when the first compliance check is passed, and terminate the operation and return a first prompt message to the user when the first compliance check is failed; The second receiving module is used to receive a second prompt message or storage success message returned by the server after sending the code upload data to the server, wherein the second prompt message and the storage success message are generated by the server after performing a second compliance check on the code upload data through server-side Git Hooks.
8. A code management device, characterized in that: The device comprises: A third receiving module receives code upload data sent by a client, wherein the code upload data is sent when the client performs a first compliance check on the code upload data through client Git Hooks and the check passes, and the code upload data includes code change information, commit information, and branch information; A second checking module performs a second compliance check on the user information and the code upload data through server-side Git Hooks. The second compliance check includes checking whether the submission type, scope, and subject fields of the submission information are consistent with preset data, and checking whether the author information in the submission information belongs to a valid user account; The warehousing module is used to complete the code warehousing according to the code upload data and return the warehousing success information to the client when the second normative check is passed, and to refuse the direct push operation and return the second prompt information to the client when it fails.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Code submission log processing method and device
CN114327588A
Code warehouse management method and system applied to chip field
CN114880227A
Code library control method and device based on Git and electronic equipment
CN116451272A
Code submission description processing method and device and electronic equipment
CN119166195A
Systems and methods for utilizing webhooks integrated in paas supported application development and deployment
US20180275966A1
