Git library shallow cloning control method and device, electronic equipment and system
By pre-processing the configuration parameters of Git dependencies and making multi-dimensional condition judgments, the target shallow cloning strategy is determined, which solves the problem of low cloning efficiency of enterprise-level Git code repositories, realizes efficient shallow cloning operations, and improves software development efficiency.
Patent Information
- Application Number
- CN202510933218.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-11-18
AI Technical Summary
Existing Git cloning strategies lack customization capabilities in enterprise-level Git codebases, resulting in inefficient cloning and an inability to efficiently complete code commits.
By performing preset processing operations on the dependency configuration parameters set by the user in the Git dependency repository configuration file, converting them into structured data, and determining the target shallow cloning strategy based on multi-dimensional joint conditions, such as a forced or default shallow cloning strategy, and performing the corresponding shallow cloning operation.
It improves the cloning efficiency of enterprise-level Git code repositories, reduces download time and storage space usage, and enhances software development efficiency.
Smart Images

Figure CN120973406A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software development, and particularly relates to a Git library shallow cloning control method, device, electronic equipment and system. BACKGROUND
[0002] Git is an open source distributed version control system, and a user can submit (Push) or download (Clone / Pull / fetch) code to a server through a client. At present, a Git downloader based on a dependency management tool (such as CocoaPods) is usually used to obtain a code repository through a git clone command, so as to realize code submission / download.
[0003] However, it is found in practice that the existing Git cloning strategy is that: only when a specific commit is not specified, a shallow cloning is automatically enabled; and when a Podfile explicitly specifies a commit, a complete cloning is forced to be performed. Using this traditional cloning strategy to process all Git code libraries lacks enterprise-level customization capability, and cannot realize efficient cloning when a code repository belongs to an enterprise-level Git code library (i.e., an enterprise private repository), which is not conducive to code submission efficiency. Therefore, it is particularly important to propose a new cloning control scheme to improve cloning efficiency. SUMMARY
[0004] The present application provides a Git library shallow cloning control method, device, electronic equipment and system, which can improve cloning efficiency when a code repository belongs to an enterprise-level Git code library, and is conducive to improving code submission efficiency.
[0005] The first aspect of the present application discloses a Git library shallow cloning control method, which is applied to an electronic equipment installed with an application program, and the electronic equipment is in communication connection with a network-attached storage device. The electronic equipment accesses the network-attached storage device through the application program, and the method is used for shallow cloning control of any Git code library in the electronic equipment or the network-attached storage device. The method comprises the following steps: performing a preset processing operation on a dependency configuration parameter set by a user in a configuration file of a predetermined Git dependency library to obtain a parameter processing result, wherein the dependency configuration parameter comprises one or more combinations of a Git code library address parameter, a branch parameter and a shallow parameter; If the user specifies the branch parameter, a target shallow cloning strategy for the Git dependency library is determined according to the parameter processing result and a preset multi-dimension joint condition, and a shallow cloning operation corresponding to the target shallow cloning strategy is performed on the Git dependency library, the target shallow cloning strategy including a forced shallow cloning strategy or a default shallow cloning strategy. If the user does not specify the branch parameter, a shallow cloning operation corresponding to the default shallow cloning strategy is performed on the Git dependency library.
[0006] As an optional implementation, in the first aspect of the present application, the preset processing operation performed on the dependency configuration parameter set by the user in the configuration file of the predetermined Git dependency library to obtain a parameter processing result includes: The dependency configuration parameter set by the user in the configuration file of the predetermined Git dependency library is obtained, and the dependency configuration parameter is parsed to obtain at least one key parameter of the configuration file; Based on a preset security verification mechanism, a first security verification operation is performed on all the key parameters; When the verification is passed, all the key parameters and the security hardened parameter obtained after the first security verification operation are taken as a complete parameter set, and the complete parameter set is optimized and reorganized to form a double configuration object containing all the key parameters and the security hardened parameter obtained after the first security verification operation, as the parameter processing result.
[0007] As an optional implementation, in the first aspect of the present application, the target shallow cloning strategy for the Git dependency library is determined according to the parameter processing result and a preset multi-dimension joint condition, including: According to the parameter processing result and a preset multi-dimension joint condition, it is judged whether the Git dependency library satisfies a preset forced shallow cloning starting condition, to obtain a judgment result; When the judgment result is that the Git dependency library satisfies the forced shallow cloning starting condition, the forced shallow cloning strategy is determined as the target shallow cloning strategy required to be performed on the Git dependency library; When the judgment result is that the Git dependency library does not satisfy the forced shallow cloning starting condition, the default shallow cloning strategy is determined as the target shallow cloning strategy required to be performed on the Git dependency library; And, the shallow cloning operation corresponding to the target shallow cloning strategy performed on the Git dependency library includes: According to the parameter processing result, a git command parameter for the Git dependency library under the target shallow cloning strategy is determined; Based on the preset security verification mechanism, a second security verification operation is performed on the git command parameter; and when the verification is passed, a shallow cloning operation corresponding to the target shallow cloning strategy is performed on the Git dependency library by running the git command parameter corresponding to the target shallow cloning strategy.
[0008] As an optional implementation, in the first aspect of the present application, the judgment result is obtained by judging whether the Git dependency library meets the preset forced shallow cloning starting condition according to the parameter processing result and a preset multi-dimensional joint condition. The Git dependency library is identified to obtain identification information of the Git dependency library, and it is judged whether the Git dependency library belongs to a preset target library according to the identification information of the Git dependency library, which is recorded as a first condition, and the target library is an enterprise internal code library of the enterprise where the user is located. It is judged whether the Git code library address parameter of the Git dependency library belongs to a domain name list of the target library according to the Git code library address parameter contained in the parameter processing result, which is recorded as a second condition. It is judged whether the shallow parameter in the configuration file of the Git dependency library is specified as a parameter for shallow cloning according to the shallow parameter contained in the parameter processing result, which is recorded as a third condition, and the shallow parameter includes a parameter for shallow cloning or a parameter for not performing shallow cloning. When the first condition, the second condition and the third condition are all met, it is determined that the judgment result is that the Git dependency library meets the preset forced shallow cloning starting condition; when at least one of the first condition, the second condition and the third condition is not met, it is determined that the judgment result is that the Git dependency library does not meet the preset forced shallow cloning starting condition.
[0009] As an optional implementation, in the first aspect of the present application, the git command parameter for the Git dependency library under the target shallow cloning strategy is determined according to the parameter processing result. When the target shallow cloning strategy is the default shallow cloning strategy, a parameter list of the git clone command is constructed as the git command parameter of the Git dependency. When the target shallow cloning strategy is the forced shallow cloning strategy, a parameter list of the git clone command is constructed, and a target parameter preset is added in the parameter list according to the parameter processing result to obtain an updated parameter list; the updated parameter list is determined as the git command parameter of the Git dependency.
[0010] As an optional implementation, in the first aspect of the present application, when the user specifies the branch parameter, the parameter processing result further includes a current hash value corresponding to the branch parameter. The current hash value is determined by the following manner: The current hash value of the branch indicated by the branch parameter is determined based on a first preset regular expression.
[0011] As an optional implementation, in the first aspect of the present application, the method further includes: detecting an execution result of the shallow cloning operation, the execution result being used to represent a cloning result of the target shallow cloning strategy, and the cloning result including a result of successful shallow cloning or a result of failed shallow cloning; When the execution result is detected to represent the result of failed shallow cloning, based on a preset error fallback mechanism, a second preset regular expression is used to identify the git command parameter, to obtain an error type of the git command parameter; and according to the error type of the git command parameter, an exception handling strategy corresponding to the error type is determined, and according to the exception handling strategy, an exception handling operation for the error type is performed.
[0012] The second aspect of the present application discloses a shallow cloning control device for a Git library. The device is applied to an electronic device installed with an application program, and the electronic device is in communication connection with a network-attached storage device. The electronic device accesses the network-attached storage device through the application program. The device is used to control shallow cloning of any Git code library in the electronic device or the network-attached storage device. The device includes: A parameter preprocessing module is used to perform a preset processing operation on a dependency configuration parameter set by a user in a configuration file of a predetermined Git dependency library, to obtain a parameter processing result. The dependency configuration parameter includes one or more combinations of a Git code library address parameter, a branch parameter, and a shallow parameter. A strategy decision module is used to determine a target shallow cloning strategy for the Git dependency library according to the parameter processing result and a preset multi-dimensional joint condition if the user specifies the branch parameter. The target shallow cloning strategy includes a forced shallow cloning strategy or a default shallow cloning strategy. The Git dependency library is subjected to a shallow cloning operation corresponding to the target shallow cloning strategy. The strategy decision module is further used to perform a shallow cloning operation corresponding to the default shallow cloning strategy on the Git dependency library if the user does not specify the branch parameter.
[0013] As an optional implementation, in the second aspect of the present application, the parameter preprocessing module performs a preset processing operation on the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library, and the manner of obtaining the parameter processing result specifically includes: Obtaining the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library, and parsing the dependency configuration parameters to obtain at least one key parameter of the configuration file; Based on the preset security verification mechanism, performing a first security verification operation on all the key parameters; When the verification is passed, all the key parameters and the security hardened parameters obtained after the first security verification operation are taken as a complete parameter set, and the complete parameter set is optimized and reorganized to form a double configuration object containing all the original key parameters and the security hardened parameters obtained after the first security verification operation, as the parameter processing result.
[0014] As an optional implementation, in the second aspect of the present application, the policy decision module determines the target shallow cloning strategy for the Git dependency library according to the parameter processing result and the preset multi-dimensional joint condition, and the manner specifically includes: According to the parameter processing result and the preset multi-dimensional joint condition, it is judged whether the Git dependency library meets the preset forced shallow cloning start condition, and a judgment result is obtained; When the judgment result is that the Git dependency library meets the forced shallow cloning start condition, the forced shallow cloning strategy is determined as the target shallow cloning strategy required to be executed for the Git dependency library; When the judgment result is that the Git dependency library does not meet the forced shallow cloning start condition, the default shallow cloning strategy is determined as the target shallow cloning strategy required to be executed for the Git dependency library; And, the shallow cloning operation corresponding to the target shallow cloning strategy for the Git dependency library includes: According to the parameter processing result, the git command parameters for the Git dependency library under the target shallow cloning strategy are determined; Based on the preset security verification mechanism, a second security verification operation is performed on the git command parameters; and when the verification is passed, the shallow cloning operation corresponding to the target shallow cloning strategy for the Git dependency library is implemented by running the git command parameters corresponding to the target shallow cloning strategy.
[0015] As an optional implementation, in the second aspect of the present application, the mode that the policy decision module determines whether the Git dependent library meets the preset mandatory shallow cloning starting condition according to the parameter processing result and a preset multi-dimensional joint condition specifically includes: identifying the Git dependent library to obtain identification information of the Git dependent library, and judging whether the Git dependent library belongs to a preset target library according to the identification information of the Git dependent library, denoted as a first condition, the target library being an enterprise internal code library of an enterprise where the user is located; judging whether the Git code repository address parameter of the Git dependent library belongs to a domain name list of the target library according to the Git code repository address parameter contained in the parameter processing result, denoted as a second condition; judging whether the shallow parameter in the configuration file of the Git dependent library is specified as a parameter for shallow cloning according to the shallow parameter contained in the parameter processing result, denoted as a third condition, the shallow parameter including a parameter for shallow cloning or a parameter for not performing shallow cloning; wherein, when the first condition, the second condition and the third condition are all met, it is determined that the judgment result is that the Git dependent library meets the preset mandatory shallow cloning starting condition; when at least one of the first condition, the second condition and the third condition is not met, it is determined that the judgment result is that the Git dependent library does not meet the preset mandatory shallow cloning starting condition.
[0016] As an optional implementation, in the second aspect of the present application, the mode that the policy decision module determines the git command parameter of the Git dependent library under the target shallow cloning strategy according to the parameter processing result specifically includes: when the target shallow cloning strategy is the default shallow cloning strategy, constructing a parameter list of the git clone command as the git command parameter of the Git dependent; when the target shallow cloning strategy is the mandatory shallow cloning strategy, constructing a parameter list of the git clone command; and adding a preset target parameter in the parameter list according to the parameter processing result to obtain an updated parameter list; determining the updated parameter list as the git command parameter of the Git dependent.
[0017] As an optional implementation, in the second aspect of the present application, when the user specifies the branch parameter, the parameter processing result further includes a current hash value corresponding to the branch parameter; wherein, the current hash value is determined by the following mode: determine the current hash value of the branch indicated by the branch parameter based on the first preset regular expression.
[0018] As an optional implementation, in the second aspect of the present application, the device further comprises: a clone detection module, configured to detect an execution result of the shallow clone operation, the execution result being used to represent a clone result of the target shallow clone strategy, and the clone result comprising a result of successful shallow clone or a result of failed shallow clone; an exception handling module, configured to, when detecting that the execution result represents the result of failed shallow clone, identify the git command parameter based on a second preset regular expression according to a preset error fallback mechanism to obtain an error type of the git command parameter, determine an exception handling strategy corresponding to the error type of the git command parameter according to the error type of the git command parameter, and perform an exception handling operation for the error type according to the exception handling strategy.
[0019] The third aspect of the present application discloses an electronic device, comprising: a memory storing executable program codes; a processor coupled with the memory; the processor invokes the executable program codes stored in the memory to execute part or all of the steps of the shallow clone control method of the Git repository according to any one of the first aspect of the present application.
[0020] The fourth aspect of the present application discloses a shallow clone control system of a Git repository, the system at least comprising the shallow clone control device of the Git repository according to the second aspect of the present application, and a network-attached storage device in communication connection with the shallow clone control device of the Git repository, and the network-attached storage device storing dependency configuration parameters of a plurality of Git code repositories, when the shallow clone control device of the Git repository performs shallow clone control on any one of the Git code repositories, the shallow clone control device of the Git repository completes a shallow clone operation for the Git code repository according to the shallow clone control method of the Git repository according to any one of the first aspect of the present application and based on the dependency configuration parameters of the Git code repository. or, the system at least comprising the electronic device according to the third aspect of the present application, and a network-attached storage device in communication connection with the electronic device, and the network-attached storage device storing dependency configuration parameters of a plurality of Git code repositories, when the electronic device performs shallow clone control on any one of the Git code repositories, the electronic device completes a shallow clone operation for the Git code repository according to the shallow clone control method of the Git repository according to any one of the first aspect of the present application and based on the dependency configuration parameters of the Git code repository.
[0021] The fifth aspect of the present application discloses a computer storage medium, which stores computer instructions, when called, for performing part or all steps of the shallow cloning control method of the Git library of any one of the first aspect of the present application.
[0022] Compared with the prior art, the present application has the following beneficial effects: Implementing the present application can perform preset processing operations on the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library (such as an enterprise-level Git code library), such as the Git code library address parameter, the branch parameter, and the shallow parameter, to obtain a parameter processing result. This converts the user's natural language configuration into structured data that can be processed by the system, which is conducive to improving the stability and predictability of the system through a standardized data structure and reducing the complexity of subsequent processing. If the user specifies the branch parameter, the target shallow cloning strategy for the Git dependency library is determined according to the parameter processing result and the preset multi-dimensional joint condition, such as the forced shallow cloning strategy or the default shallow cloning strategy, so that the target shallow cloning strategy is executed. This way, in the case of an enterprise-level Git code library, compared to the existing forced shallow cloning when the user specifies the branch parameter, the present solution performs forced shallow cloning or default shallow cloning through multi-dimensional joint conditions, which can achieve efficient shallow cloning and is conducive to reducing the situation of long download time and large storage space occupation caused by forced shallow cloning in enterprise private repositories, thereby improving software development efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0024] Figure 1 is a flowchart of a shallow cloning control method of a Git library disclosed by an embodiment of the present application; Figure 2 is a flowchart of a configuration parameter preprocessing process of a dependency configuration parameter disclosed by an embodiment of the present application; Figure 3 is a flowchart of a cloning strategy decision disclosed by an embodiment of the present application; Figure 4is a flow diagram of another Git library shallow cloning control method disclosed by the embodiment of the present application; Figure 5 is a Git code library cloning flow architecture diagram disclosed by the embodiment of the present application; Figure 6 is a Git library shallow cloning control device structure diagram disclosed by the embodiment of the present application; Figure 7 is another Git library shallow cloning control device structure diagram disclosed by the embodiment of the present application; Figure 8 is still another Git library shallow cloning control device structure diagram disclosed by the embodiment of the present application; Figure 9 is a Git library shallow cloning control system structure diagram disclosed by the embodiment of the present application; Figure 10 is another Git library shallow cloning control system structure diagram disclosed by the embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by persons skilled in the art without creative labor fall within the scope of protection of the present application.
[0026] The terms "first", "second", and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, and are not used to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product, or end including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product, or end.
[0027] In this document, the term "embodiment" means that the specific features, structures, or characteristics described in connection with the embodiment can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor is it independent or alternative to other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0028] The application discloses a shallow cloning control method, device, electronic equipment and system of a Git library, which can perform a preset processing operation on a dependency configuration parameter set by a user in a configuration file of a predetermined Git dependency library (such as an enterprise-level Git code library), such as a Git code library address parameter, a branch parameter and a shallow parameter, to obtain a parameter processing result, so that natural language configuration of the user is converted into structured data that can be processed by the system, which is beneficial to improving the stability and predictability of the system through a standardized data structure and reducing the complexity of subsequent processing. If the user specifies the branch parameter, a target shallow cloning strategy for the Git dependency library, such as a forced shallow cloning strategy or a default shallow cloning strategy, is determined according to the parameter processing result and a preset multidimensional joint condition, so that the target shallow cloning strategy is executed. In the case of an enterprise-level Git code library, compared with the existing forced shallow cloning when the user specifies the branch parameter, the present application can realize efficient shallow cloning by executing forced shallow cloning or default shallow cloning through multidimensional joint conditions, which is beneficial to reducing the situation that the enterprise private repository takes a long time to download and occupies a large amount of storage space due to forced shallow cloning, thereby improving the software development efficiency. If the user does not specify the branch parameter, a default shallow cloning operation is directly performed on the Git dependency library, which improves the shallow cloning efficiency of the Git dependency library in the case that the user does not specify the branch parameter. The following will be described in detail.
[0029] Embodiment one Please refer to Figure 1 , Figure 1 is a flowchart of a shallow cloning control method of a Git library disclosed by the application. Wherein, Figure 1 The shallow cloning control method of the Git library described above can be applied to an electronic device installed with an application, and the electronic device is in communication connection with a network attached storage device. The electronic device accesses the network attached storage device through the application, and the method is used for shallow cloning control of any Git code library in the electronic device or the network attached storage device. The method can also be applied to a shallow cloning control device of the Git library, wherein the device can include one of a shallow cloning control device, a shallow cloning control system (a local system or a cloud system) and a shallow cloning control server (a local server or a cloud server). The shallow cloning control device includes but is not limited to a mobile phone, a computer, a tablet and other devices that can support shallow cloning operation, and the application does not limit the embodiment. Figure 1 As shown in the figure, the shallow cloning control method of the Git library can include the following operations: 101. Perform a preset processing operation on a dependency configuration parameter set by a user in a configuration file of a predetermined Git dependency library, and obtain a parameter processing result.
[0030] In the embodiment of the application, optionally, the dependency configuration parameter set by the user in the configuration file (Podfile) of the Git dependency library can be a parameter configured by the user through natural language. The dependency configuration parameter can include one or more combinations of a Git code library address parameter (URL), a branch parameter (branch name, tag or commit), a shallow parameter (whether to perform shallow cloning) and other related configuration parameters. Optionally, the preset processing operation includes at least an operation of parsing the Podfile parameter and an operation of parameter security verification, and further optionally, when the user specifies the branch parameter through the dependency configuration parameter, the preset processing operation further includes an operation of dynamic branch processing, so that the natural language configuration of the user is converted into structured data that can be processed by the system through the processing of the dependency configuration parameter, thereby providing a basis for subsequent processing, and the embodiment of the application is not limited.
[0031] 102、If the user specifies the branch parameter, a target shallow cloning strategy for the Git dependency library is determined according to the parameter processing result and a preset multi-dimensional joint condition, and a shallow cloning operation corresponding to the target shallow cloning strategy is performed on the Git dependency library.
[0032] In the embodiment of the application, the target shallow cloning strategy includes a forced shallow cloning strategy or a default shallow cloning strategy. When the target shallow cloning strategy is the forced shallow cloning strategy, the corresponding shallow cloning operation is forced shallow cloning operation. When the target shallow cloning strategy is the default shallow cloning strategy, the corresponding shallow cloning operation is default shallow cloning strategy. The default shallow cloning (original mechanism of CocoaPods) is a shallow cloning strategy automatically enabled by CocoaPods under a specific condition, and the specific condition can be a condition that any version control parameter (commit / branch / tag) is not specified. The forced shallow cloning strategy is triggered through multi-dimensional joint conditions (such as trinity conditions), so that even in a scenario in which CocoaPods originally performs complete cloning, shallow cloning is forced to be used.
[0033] 103、If the user does not specify the branch parameter, a shallow cloning operation corresponding to the default shallow cloning strategy is performed on the Git dependency library.
[0034] It can be seen that the implementation Figure 1The described shallow cloning control method of the Git library can perform a preset processing operation on the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library (such as an enterprise-level Git code library), such as the Git code library address parameter, the branch parameter, and the shallow parameter, to obtain a parameter processing result. This converts the user's natural language configuration into structured data that can be processed by the system, which is conducive to improving the stability and predictability of the system through standardized data structures and reducing the complexity of subsequent processing. If the user specifies the branch parameter, the target shallow cloning strategy for the Git dependency library is determined according to the parameter processing result and the preset multi-dimensional joint condition, such as the forced shallow cloning strategy or the default shallow cloning strategy, and the target shallow cloning strategy is executed. This way, in the case of an enterprise-level Git code library, compared to the existing forced shallow cloning when the user specifies the branch parameter, this scheme performs forced shallow cloning or default shallow cloning through multi-dimensional joint conditions, enabling efficient shallow cloning and reducing the likelihood of long download times and large storage space usage due to forced shallow cloning in enterprise private repositories, thereby improving software development efficiency. If the user does not specify the branch parameter, the default shallow cloning operation is directly performed on the Git dependency library, which improves the shallow cloning efficiency and efficiency of the Git dependency library when the user does not specify the branch parameter.
[0035] In an optional embodiment, the above step 101 of performing a preset processing operation on the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library to obtain a parameter processing result can include: Obtain the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library and parse the dependency configuration parameters to obtain at least one key parameter of the configuration file; Based on a preset security verification mechanism, perform a first security verification operation on all key parameters; When the verification is passed, all key parameters and security hardened parameters obtained after the first security verification operation are taken as a complete parameter set, and the complete parameter set is optimized and reorganized to form a dual configuration object containing all original key parameters and security hardened parameters obtained after the first security verification operation, as the parameter processing result.
[0036] In the embodiment of the application, firstly, the operation of analyzing Podfile is performed, specifically, the system first receives the dependency configuration information defined by the user in the Podfile, extracts the Git code repository URL, branch name, whether to shallow clone and other key parameters, and organizes these parameters into a structured configuration object, wherein the structured configuration object contains all necessary cloning parameters, can realize the conversion of the user's natural language configuration into structured data that can be processed by the system, and through the standardized data structure, the stability and predictability of the system are improved, and the complexity of subsequent processing is reduced; then the parameter security verification operation is performed, wherein the first security verification operation includes URL format legality verification, parameter value security check (to prevent command injection), dangerous character rejection (such as parameters starting with --), parameter type and value range verification and other security verification operations on all input parameters in all cloning parameters used as input, so as to ensure that the parameter set verified for security does not contain dangerous content, and to prevent command injection attacks from the source, protect the safety of the CI / CD system and the development environment, and reduce potential security risks.
[0037] Further, it is detected whether the user specifies the branch parameter; and when it is detected that the user specifies the branch parameter, a dynamic branch processing operation is performed on the branch parameter; if the user directly specifies the commit or tag, this step is not needed.
[0038] Finally, the complete parameter set extracted after security verification is optimized and reorganized to form a dual configuration object containing original parameters and security hardened parameters: the original URL, branch and other parameters are retained for efficient cloning operation, and the corresponding commit hash value is added for security checkout, together with the shallow parameter and other configurations, to form the final parameter output, as shown in Figure 2 Figure 2 is a flowchart of a configuration parameter preprocessing flow of a dependency configuration parameter disclosed by the embodiment of the application, and Figure 2 is an example of a full flow of the configuration parameter preprocessing flow including the operations of analyzing Podfile parameters, parameter security verification, dynamic branch processing and final parameter extraction.
[0039] It can be seen that the optional embodiment can obtain the dependency configuration parameters set by the user in the configuration file in the predetermined Git dependency library, and parse the dependency configuration parameters to obtain at least one key parameter of the configuration file. In this way, the parameters configured by the user through natural language are organized into a structured configuration object, which is beneficial to improve the stability and predictability of the system, and is beneficial to reduce the complexity of subsequent processing. Then, based on the preset security verification mechanism, a first security verification operation is performed on all key parameters. When the verification is passed, all key parameters and security hardened parameters obtained after the first security verification operation are taken as a complete parameter set, and the complete parameter set is optimized and reorganized to form a double configuration object containing all key parameters and security hardened parameters obtained after the first security verification operation, as a parameter processing result. In this way, it is ensured that the parameter set after security verification does not contain dangerous content, which is beneficial to provide a stable and reliable data foundation for subsequent shallow cloning processing, and facilitates the implementation of subsequent shallow cloning.
[0040] In another optional embodiment, the step 102 of determining the target shallow cloning strategy for the Git dependency library according to the parameter processing result and the preset multi-dimensional joint condition can include: According to the parameter processing result and the preset multi-dimensional joint condition, it is determined whether the Git dependency library satisfies the preset forced shallow cloning starting condition, and a judgment result is obtained. When the judgment result is that the Git dependency library satisfies the forced shallow cloning starting condition, a forced shallow cloning strategy is determined as the target shallow cloning strategy required to be executed on the Git dependency library. When the judgment result is that the Git dependency library does not satisfy the forced shallow cloning starting condition, a default shallow cloning strategy is determined as the target shallow cloning strategy required to be executed on the Git dependency library. And, the target shallow cloning strategy corresponding shallow cloning operation is executed on the Git dependency library, including: According to the parameter processing result, the git command parameters for the Git dependency library under the target shallow cloning strategy are determined. Based on the preset security verification mechanism, a second security verification operation is performed on the git command parameters. When the verification is passed, the target shallow cloning strategy corresponding shallow cloning operation is implemented on the Git dependency library by running the git command parameters.
[0041] In the embodiment of the present application, the multi-dimension combined condition can include judgment conditions of multiple (for example, three) independent dimensions, and can judge whether to enable forced shallow cloning through the judgment conditions of multiple independent dimensions. Optionally, all judgment conditions of independent dimensions can include at least two of a judgment condition depending on a library identifier, a domain name judgment condition based on a Git code library address parameter, and a judgment condition of a specified shallow cloning based on a shallow parameter, and the embodiment of the present application is not limited.
[0042] In the embodiment of the present application, specifically, according to the parameter processing result, the git command parameters of the Git dependency under different shallow cloning strategies are constructed. The git command parameters can be a parameter list of a git clone command, and the constructed git clone command parameter list is a cloning parameter required for executing a shallow cloning strategy. In this way, for different cloning strategies, the optimal command parameters are dynamically generated according to the foregoing decision result.
[0043] In the embodiment of the present application, the first security verification operation and the second security verification operation can use the same security verification mechanism, that is, the first security verification operation and the second security verification operation are the application of the same security verification logic in different stages. For the first security verification operation, preventive verification is performed in the parameter analysis stage, which is used for preliminary security check of all input parameters, and the purpose is to intercept dangerous input before the processing flow starts. For the second security verification operation, final security confirmation is performed before command execution, which is used for secondary verification of parameters to be used for constructing a Git command, and the purpose is to provide the last security defense line before execution.
[0044] It can be seen that the optional embodiment can determine whether the Git dependency library meets the preset mandatory shallow cloning starting condition by parameter processing result and the preset multi-dimensional joint condition, obtain a judgment result, and determine the mandatory shallow cloning strategy as the target shallow cloning strategy required to be executed on the Git dependency library when it is judged that the mandatory shallow cloning starting condition is met, thereby improving the determination accuracy and reliability of the strategy required to be executed on the Git dependency library as the mandatory shallow cloning strategy. When it is judged that the mandatory shallow cloning starting condition is not met, the default shallow cloning strategy is determined as the target shallow cloning strategy required to be executed on the Git dependency library, thereby improving the determination accuracy and reliability of the strategy required to be executed on the Git dependency library as the default shallow cloning strategy. After the strategy to be executed is determined, the git command parameters of the Git dependency library under different strategies are determined according to the parameter processing result, so that the optimal command parameters can be dynamically generated according to the foregoing decision result for different cloning strategies. Then, the second security verification operation is performed on the git command parameters based on the security verification mechanism, and when the verification is passed, the shallow cloning operation corresponding to the target shallow cloning strategy is implemented on the Git dependency library by running the git command parameters corresponding to the target shallow cloning strategy, so that the final security confirmation of the cloning parameters before command execution is realized, which is conducive to ensuring the accuracy and reliability of the cloning parameters, thereby further improving the execution accuracy and reliability of the mandatory shallow cloning strategy and the default shallow cloning strategy.
[0045] In this optional embodiment, as an optional implementation, determining whether the Git dependency library meets the preset mandatory shallow cloning starting condition according to the parameter processing result and the preset multi-dimensional joint condition to obtain a judgment result can include: Identifying the Git dependency library to obtain identification information of the Git dependency library, and determining whether the Git dependency library belongs to a preset target library according to the identification information of the Git dependency library, denoted as a first condition, and the target library is an enterprise internal code library of a user's enterprise; Determining whether the Git dependency library address parameter of the Git dependency library belongs to the domain name list of the target library according to the Git code library address parameter contained in the parameter processing result, denoted as a second condition; Determining whether the shallow parameter in the configuration file of the Git dependency library is specified as a shallow cloning parameter according to the shallow parameter contained in the parameter processing result, denoted as a third condition, and the shallow parameter includes a shallow cloning parameter or a non-shallow cloning parameter; When the first condition, the second condition and the third condition are all met, it is determined that the judgment result is that the Git dependency library meets the preset mandatory shallow cloning starting condition. When at least one of the first condition, the second condition and the third condition is not met, it is determined that the judgment result is that the Git dependency library does not meet the preset mandatory shallow cloning starting condition.
[0046] In the embodiment of the present application, specifically, for the first condition, the library name prefix of the Git dependency library is identified to check whether the name of the Git dependency library starts with a preset string (for example, "UG"); if yes, it indicates that the Git dependency library belongs to the enterprise internal library; if no, it indicates that the Git dependency library does not belong to the enterprise internal library. For the second condition, the enterprise domain name whitelist verification is performed through the Git code repository address parameter, specifically: verifying whether the git URL belongs to the enterprise internal repository domain name list. For the third condition, the explicit configuration check is performed through the shallow parameter, specifically: checking whether the shallow parameter is explicitly specified as true in the Podfile. Only when the three conditions are met at the same time, the forced shallow cloning strategy is enabled, which ensures that the optimization strategy is applied only to the enterprise internal controlled repository through multi-dimensional judgment.
[0047] Specifically, the cloning strategy decision process is as follows: the Git dependency library is judged through the Trinity condition to obtain a judgment result, wherein when the judgment result indicates that the condition is met, the forced shallow cloning is adopted; when the judgment result indicates that the condition is not met or the user does not specify the submission, the default shallow cloning is adopted; and in other cases, the complete cloning is adopted. The process of the cloning strategy decision is shown in Figure 3 . Figure 3 is a process diagram of the cloning strategy decision disclosed in the embodiment of the present application.
[0048] It can be seen that the optional implementation can identify the Git dependency library, obtain the identification information of the Git dependency library, and judge whether the Git dependency library belongs to the preset target library according to the identification information of the Git dependency library, which is recorded as the first condition. According to the Git code repository address parameter contained in the parameter processing result, it is judged whether the Git code repository address parameter of the Git dependency library belongs to the domain name list of the target library, which is recorded as the second condition. According to the shallow parameter contained in the parameter processing result, it is judged whether the shallow parameter is specified in the configuration file of the Git dependency library as the parameter for shallow cloning, which is recorded as the third condition. In this way, the multi-dimensional judgment improves the accuracy and reliability of the decision, reduces the misjudgment rate, ensures that the optimization strategy is applied only to the suitable library, and avoids potential problems caused by the unsuitable library.
[0049] In the optional embodiment, as another optional implementation, according to the parameter processing result, the git command parameters for the Git dependency library under the target shallow cloning strategy can include: When the target shallow cloning strategy is the default shallow cloning strategy, the parameter list of the git clone command is constructed as the git command parameters of the Git dependency; When the target shallow clone strategy is the forced shallow clone strategy, a parameter list of the git clone command is constructed; and according to a parameter processing result, a target parameter preset in the parameter list is added to obtain an updated parameter list; and the updated parameter list is determined as a git command parameter of the Git dependency.
[0050] In the embodiment of the application, specifically, when it is determined based on the multi-dimensional joint condition that the Git dependency library does not satisfy the forced shallow clone starting condition, it is determined to use the default shallow clone strategy, at this time, a standard git clone parameter list is constructed, so that the default shallow clone strategy follows the original logic; when it is determined based on the multi-dimensional joint condition that the Git dependency library satisfies the forced shallow clone starting condition, it is determined to use the forced shallow clone strategy, at this time, a standard git clone parameter list is constructed, and a target parameter is added to the parameter list, for example, the “--single-branch --depth 1” parameter is added, so that the git clone parameter list constructed is a parameter list containing “--single-branch --depth 1”, so as to ensure that even if the user specifies a commit, the shallow clone is forced to be used.
[0051] It can be seen that the optional embodiment can construct a git clone command parameter list corresponding to different strategies by determining whether the target shallow clone strategy is the forced shallow clone strategy or the default shallow clone strategy, so as to improve the construction accuracy, flexibility and reliability of the git clone command parameter list, thereby further improving the execution accuracy and reliability of the subsequent shallow clone strategy.
[0052] In the optional embodiment, when the user specifies the branch parameter, the parameter processing result further includes a current hash value corresponding to the branch parameter. The current hash value is determined by the following method: The current hash value of the branch indicated by the branch parameter is determined based on a first preset regular expression.
[0053] In the embodiment of the application, specifically, when the user specifies the branch parameter, the system does not directly use this dynamic reference, but extracts the current commit hash value of the branch from the git ls-remote command through the first preset regular expression, wherein the first preset regular expression is used to process the reference (refs) related data of the Git, and when the remote repository reference of the Git is parsed, the name of the branch or the label is extracted through the first preset regular expression.
[0054] It can be seen that in the process of processing the configuration parameter, when the user specifies the branch parameter, the optional embodiment can perform dynamic branch processing operation to accurately and clearly convert the dynamic branch parameter into an immutable commit hash, prevent man-in-the-middle attack, help eliminate the security risk caused by branch reference change, ensure the consistency and reproducibility of the code version, and help retain the convenience of using branch names for users.
[0055] Embodiment two Please refer to Figure 4 , Figure 4 is another flowchart of the Git library shallow cloning control method disclosed by the embodiment of the application. Wherein, Figure 4 The Git library shallow cloning control method described can be applied to an electronic device installed with an application, and the electronic device is in communication connection with a network attached storage device, the electronic device accesses the network attached storage device through the application, and the method is used for shallow cloning control of any Git code library in the electronic device or the network attached storage device; the method can also be applied to a Git library shallow cloning control device, wherein the device can include a shallow cloning control device or a shallow cloning control system or a shallow cloning control server, and the device can include one of a shallow cloning control device, a shallow cloning control system (a local system or a cloud system), and a shallow cloning control server (a local server or a cloud server). Wherein, the shallow cloning control device includes but is not limited to a mobile phone, a computer, a tablet and other devices that can support shallow cloning operation, and the embodiment of the application is not limited. As shown in Figure 4 The Git library shallow cloning control method can include the following operations: 201, performing a preset processing operation on the dependency configuration parameter set by the user in the configuration file of the predetermined Git dependency library to obtain a parameter processing result.
[0056] 202, if the user specifies the branch parameter, determining a target shallow cloning strategy for the Git dependency library according to the parameter processing result and a preset multi-dimensional joint condition, and performing a shallow cloning operation corresponding to the target shallow cloning strategy on the Git dependency library.
[0057] 203, if the user does not specify the branch parameter, performing a shallow cloning operation corresponding to a default shallow cloning strategy on the Git dependency library.
[0058] In the embodiment of the application, for other descriptions of steps 201-203, please refer to the detailed description of steps 101-103 in embodiment one, and the embodiment of the application will not be repeated.
[0059] 204, detecting the execution result of the shallow cloning operation.
[0060] In the embodiment of the present application, the execution result is used to represent the cloning result of the target shallow cloning strategy, and the cloning result includes a result of successful shallow cloning or a result of failed shallow cloning.
[0061] Optionally, the detected shallow cloning operation at least includes: forced shallow cloning operation corresponding to the forced shallow cloning strategy executed under the condition that the user specifies the branch parameter, or default shallow cloning operation corresponding to the default shallow cloning strategy executed under the condition that the user specifies the branch parameter, or default shallow cloning operation corresponding to the default shallow cloning strategy executed under the condition that the user does not specify the branch parameter, which is not limited in the embodiment of the present application.
[0062] 205、When it is detected that the execution result represents the result of failed shallow cloning, the git command parameter is identified based on a second preset regular expression according to a preset error fallback mechanism, so as to obtain an error type of the git command parameter.
[0063] In the embodiment of the present application, the second preset regular expression is used to match a specific error type when processing the Git operation, for example, an error type of not supporting shallow cloning. In this way, the errors can be quickly identified and processed by the second preset regular expression.
[0064] 206、According to the error type of the git command parameter, an exception handling strategy corresponding to the error type is determined, and an exception handling operation for the error type is executed according to the exception handling strategy.
[0065] For example, when the error type is the type of not supporting shallow cloning, the strategy of complete cloning is executed. In this way, after the configuration parameter preprocessing and the cloning strategy decision, the process of safe execution and error handling is set, which is beneficial to improve the cloning success rate and the cloning efficiency, thereby being beneficial to improve the success rate of code submission. Figure 5 As shown in FIG. 1, Figure 5 is a schematic diagram of a cloning process architecture of a Git code repository disclosed by the embodiment of the present application, and Figure 5 is an example of the cloning full process including configuration parameter preprocessing, cloning strategy decision and safe execution and error handling.
[0066] It can be seen that the embodiment of the present application Figure 4The described shallow cloning control method of the Git library can perform preset processing operations on the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library (such as an enterprise-level Git code library), such as the Git code library address parameter, the branch parameter, and the shallow parameter, to obtain a parameter processing result. In this way, the natural language configuration of the user is converted into structured data that can be processed by the system, which is conducive to improving the stability and predictability of the system through a standardized data structure, and reducing the complexity of subsequent processing. If the user specifies the branch parameter, the target shallow cloning strategy for the Git dependency library is determined according to the parameter processing result and a preset multi-dimensional joint condition, such as a forced shallow cloning strategy or a default shallow cloning strategy, so that the target shallow cloning strategy is executed. In the case of an enterprise-level Git code library, compared with the existing forced shallow cloning when the user specifies the branch parameter, the present scheme can achieve efficient shallow cloning by performing forced shallow cloning or default shallow cloning through multi-dimensional joint conditions, which is conducive to reducing the situation that the enterprise private repository takes a long time to download and occupies a large amount of storage space due to the use of forced shallow cloning, thereby improving the software development efficiency. If the user does not specify the branch parameter, the default shallow cloning operation is directly performed on the Git dependency library, which improves the shallow cloning efficiency and efficiency of the Git dependency library in the case where the user does not specify the branch parameter. In addition, after the shallow cloning strategy is executed, it can be detected whether the shallow cloning is successful, and when the shallow cloning fails, based on an error fallback mechanism, a second preset regular expression is used to identify the error type of the git command parameter, so as to determine the corresponding exception handling strategy and perform processing. In the case of Git command failure, the error reason can be accurately identified and corresponding measures can be taken, which improves the fault tolerance of the system and enables it to cope with various abnormal situations, thereby improving the success rate of code submission.
[0067] Embodiment three Please refer to Figure 6 , Figure 6 is a structural schematic diagram of a Git library shallow cloning control device disclosed by an embodiment of the present application. Wherein, Figure 6 The described Git library shallow cloning control device can be applied to an electronic device installed with an application program, and the electronic device is in communication connection with a network attached storage device. The electronic device accesses the network attached storage device through the application program. The method is used for shallow cloning control of any Git code library in the electronic device or the network attached storage device, and the device can include one of a shallow cloning control device, a shallow cloning control system (a local system or a cloud system), and a shallow cloning control server (a local server or a cloud server). The shallow cloning control device includes but is not limited to a mobile phone, a computer, a tablet, and other devices that can support shallow cloning operations, and the present application does not limit the embodiments. For example,Figure 6 The shallow clone control device of the Git library can include: The parameter preprocessing module 301 is configured to perform a preset processing operation on a dependency configuration parameter set by a user in a configuration file of a predetermined Git dependency library, to obtain a parameter processing result. The dependency configuration parameter includes one or more combinations of a Git code library address parameter, a branch parameter, and a shallow parameter.
[0068] The policy decision module 302 is configured to determine a target shallow clone strategy for the Git dependency library according to the parameter processing result and a preset multi-dimensional joint condition if the user specifies the branch parameter; and perform a shallow clone operation corresponding to the target shallow clone strategy on the Git dependency library. The target shallow clone strategy includes a forced shallow clone strategy or a default shallow clone strategy.
[0069] The policy decision module 302 is further configured to perform a shallow clone operation corresponding to the default shallow clone strategy on the Git dependency library if the user does not specify the branch parameter.
[0070] It can be seen that the implementation Figure 6 The described shallow clone control device of the Git library can perform a preset processing operation on a dependency configuration parameter set by a user in a configuration file of a predetermined Git dependency library (such as an enterprise-level Git code library), such as a Git code library address parameter, a branch parameter, and a shallow parameter, to obtain a parameter processing result. This converts the user's natural language configuration into structured data that can be processed by the system, which is beneficial to improving the stability and predictability of the system through a standardized data structure, and is beneficial to reducing the complexity of subsequent processing. If the user specifies the branch parameter, a target shallow clone strategy for the Git dependency library is determined according to the parameter processing result and a preset multi-dimensional joint condition, such as a forced shallow clone strategy or a default shallow clone strategy, so that the target shallow clone strategy is executed. In the case of a code repository belonging to an enterprise-level Git code library, compared to the existing forced shallow clone when the user specifies the branch parameter, this scheme performs forced shallow cloning or default shallow cloning through multi-dimensional joint conditions, which can achieve efficient shallow cloning and is beneficial to reducing the situation of long download time and large storage space occupation caused by forced shallow cloning in enterprise private repositories, thereby improving software development efficiency. If the user does not specify the branch parameter, the default shallow clone operation is directly performed on the Git dependency library, which improves the shallow cloning efficiency and efficiency of the Git dependency library in the case where the user does not specify the branch parameter.
[0071] In an optional embodiment, the parameter preprocessing module 301 performs a preset processing operation on the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library to obtain the parameter processing result in the following manner: Obtain the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library, and parse the dependency configuration parameters to obtain at least one key parameter of the configuration file; Perform a first security verification operation on all the key parameters based on a preset security verification mechanism; When the verification is passed, all the key parameters and the security hardened parameters obtained after the first security verification operation are taken as a complete parameter set, and the complete parameter set is optimized and reorganized to form a dual configuration object containing all the original key parameters and the security hardened parameters obtained after the first security verification operation, as the parameter processing result.
[0072] It can be seen that the optional embodiment can obtain the dependency configuration parameters set by the user in the configuration file of the predetermined Git dependency library, and parse the dependency configuration parameters to obtain at least one key parameter of the configuration file. This organizes the parameters configured by the user through natural language into a structured configuration object, which is conducive to improving the stability and predictability of the system, and reducing the complexity of subsequent processing. Then, based on a preset security verification mechanism, a first security verification operation is performed on all the key parameters. When the verification is passed, all the key parameters and the security hardened parameters obtained after the first security verification operation are taken as a complete parameter set, and the complete parameter set is optimized and reorganized to form a dual configuration object containing all the original key parameters and the security hardened parameters obtained after the first security verification operation, as the parameter processing result. This ensures that the parameter set that has passed the security verification does not contain dangerous content, which is conducive to providing a stable and reliable data foundation for subsequent shallow cloning processing, and facilitating the implementation of subsequent shallow cloning.
[0073] In another optional embodiment, the policy decision module 302 determines the target shallow cloning strategy for the Git dependency library according to the parameter processing result and a preset multi-dimensional joint condition in the following manner: According to the parameter processing result and a preset multi-dimensional joint condition, determine whether the Git dependency library meets a preset forced shallow cloning start condition to obtain a judgment result; When the judgment result is that the Git dependency library meets the forced shallow cloning start condition, determine a forced shallow cloning strategy as the target shallow cloning strategy required to be executed on the Git dependency library; When the judgment result is that the Git dependency library does not meet the forced shallow cloning start condition, determine a default shallow cloning strategy as the target shallow cloning strategy required to be executed on the Git dependency library; and performing a shallow cloning operation corresponding to the target shallow cloning strategy on the Git dependency library, including: determining the git command parameters for the Git dependency library under the target shallow cloning strategy according to the parameter processing result; performing a second security verification operation on the git command parameters based on a preset security verification mechanism; and when the verification is passed, implementing the shallow cloning operation corresponding to the target shallow cloning strategy on the Git dependency library by running the git command parameters corresponding to the target shallow cloning strategy.
[0074] It can be seen that the optional embodiment can determine whether the Git dependency library meets the preset forced shallow cloning starting condition through the parameter processing result and the preset multi-dimensional joint condition, obtain a judgment result, and when it is determined that the forced shallow cloning starting condition is met, determine the forced shallow cloning strategy as the target shallow cloning strategy required to be executed on the Git dependency library, thereby improving the determination accuracy and reliability of the strategy required to be executed on the Git dependency library as the forced shallow cloning strategy. When it is determined that the forced shallow cloning starting condition is not met, the default shallow cloning strategy is determined as the target shallow cloning strategy required to be executed on the Git dependency library, thereby improving the determination accuracy and reliability of the strategy required to be executed on the Git dependency library as the default shallow cloning strategy. After the strategy required to be executed is determined, the git command parameters for the Git dependency library under different strategies are determined according to the parameter processing result, the optimal command parameters can be dynamically generated according to the foregoing decision result for different cloning strategies. Then, based on the security verification mechanism, a second security verification operation is performed on the git command parameters, and when the verification is passed, the shallow cloning operation corresponding to the target shallow cloning strategy is implemented on the Git dependency library by running the git command parameters corresponding to the target shallow cloning strategy, which can finally confirm the cloning parameters before the command is executed, and is conducive to ensuring the accuracy and reliability of the cloning parameters, thereby further improving the execution accuracy and reliability of the forced shallow cloning strategy and the default shallow cloning strategy.
[0075] In this optional embodiment, as an optional implementation, the strategy decision module 302 determines whether the Git dependency library meets the preset forced shallow cloning starting condition according to the parameter processing result and the preset multi-dimensional joint condition, and the manner of obtaining the judgment result specifically includes: identifying the Git dependency library to obtain identification information of the Git dependency library, and determining whether the Git dependency library belongs to a preset target library according to the identification information of the Git dependency library, denoted as a first condition, and the target library is an enterprise internal code library of a user's enterprise; determining whether the Git code repository address parameter of the Git dependency library belongs to a domain name list of the target library according to the Git code repository address parameter contained in the parameter processing result, denoted as a second condition; According to the shallow parameter contained in the parameter processing result, it is judged whether the shallow parameter is specified as a parameter for performing shallow cloning in the configuration file of the Git dependent library, denoted as a third condition. The shallow parameter includes a parameter for performing shallow cloning, or a parameter for not performing shallow cloning. When the first condition, the second condition and the third condition are all satisfied, it is determined that the judgment result is that the Git dependent library satisfies the preset forced shallow cloning starting condition. When at least one of the first condition, the second condition and the third condition is not satisfied, it is determined that the judgment result is that the Git dependent library does not satisfy the preset forced shallow cloning starting condition.
[0076] It can be seen that the optional embodiment can identify the Git dependent library, obtain the identification information of the Git dependent library, and judge whether the Git dependent library belongs to a preset target library according to the identification information of the Git dependent library, denoted as a first condition. According to the Git repository address parameter contained in the parameter processing result, it is judged whether the Git repository address parameter of the Git dependent library belongs to the domain name list of the target library, denoted as a second condition. According to the shallow parameter contained in the parameter processing result, it is judged whether the shallow parameter is specified as a parameter for performing shallow cloning in the configuration file of the Git dependent library, denoted as a third condition. In this way, multi-dimensional judgment is used to improve the accuracy and reliability of decision-making, reduce the misjudgment rate, ensure that the optimization strategy is only applied to suitable libraries, and avoid potential problems caused by unsuitable libraries.
[0077] In this optional embodiment, as another optional embodiment, the manner in which the strategy decision module 302 determines the git command parameters of the Git dependent library according to the parameter processing result under the target shallow cloning strategy specifically includes: When the target shallow cloning strategy is the default shallow cloning strategy, a parameter list of the git clone command is constructed as the git command parameters of the Git dependent library. When the target shallow cloning strategy is the forced shallow cloning strategy, a parameter list of the git clone command is constructed. According to the parameter processing result, a preset target parameter is added to the parameter list to obtain an updated parameter list. The updated parameter list is determined as the git command parameters of the Git dependent library.
[0078] It can be seen that the optional embodiment can determine whether the target shallow cloning strategy is the forced shallow cloning strategy or the default shallow cloning strategy, and then use the corresponding construction strategy to construct the git clone command parameter list corresponding to different strategies as the git command parameters of the Git dependent library, thereby improving the construction accuracy, flexibility and reliability of the git clone command parameter list, and thereby facilitating further improvement of the execution accuracy and reliability of the subsequent shallow cloning strategy.
[0079] In this optional implementation, when the user specifies the branch parameter, the parameter processing result may also include the current hash value corresponding to the branch parameter; The current hash value is determined in the following way: Based on the first preset regular expression, determine the current hash value of the branch indicated by the branch parameter.
[0080] As can be seen, this optional implementation can also perform dynamic branch processing operations when the user specifies the branch parameter during the processing of configuration parameters, so as to accurately and clearly convert the dynamic branch parameter into an immutable commit hash, prevent man-in-the-middle attacks, help eliminate the security risks caused by changes in branch references, ensure the consistency and reproducibility of code versions, and at the same time help retain the convenience of users using branch names.
[0081] In yet another alternative embodiment, such as Figure 7 As shown, Figure 7 This is a schematic diagram of another shallow cloning control device for a Git repository disclosed in an embodiment of the present invention, wherein the device may further include: The clone detection module 303 is used to detect the execution result of the shallow cloning operation. The execution result is used to represent the cloning result of the target shallow cloning strategy, and the cloning result includes the result of shallow cloning success or shallow cloning failure.
[0082] The exception handling module 304 is used to identify the error type of the git command parameters based on the preset error rollback mechanism and the second preset regular expression when the execution result indicates that the shallow clone has failed. Based on the error type of the git command parameters, the module determines the exception handling strategy corresponding to the error type and executes the exception handling operation for the error type according to the exception handling strategy.
[0083] It is evident that implementation Figure 7 The described device can also detect whether the shallow clone was successful after executing the shallow clone strategy, and when the shallow clone fails, it can identify the error type of the git command parameters based on the error rollback mechanism and through the second preset regular expression, thereby determining the corresponding exception handling strategy and handling it. It can accurately identify the error cause and take corresponding measures when the Git command fails, which improves the fault tolerance of the system and enables it to cope with various abnormal situations, thereby helping to improve the success rate of code submission.
[0084] Example 4 Please see Figure 8 , Figure 8is a structural schematic diagram of still another Git library shallow cloning control device disclosed by the embodiment of the present application. As shown in Figure 8 , the Git library shallow cloning control device can include: a memory 401 storing executable program codes; a processor 402 coupled with the memory 401; The processor 402 invokes the executable program codes stored in the memory 401 to execute part or all of the steps of the Git library shallow cloning control method described in the embodiment one or the embodiment two of the present application.
[0085] Embodiment five Please refer to Figure 9 , Figure 9 is a structural schematic diagram of a Git library shallow cloning control system disclosed by the embodiment of the present application. As shown in Figure 9 , the Git library shallow cloning control system at least includes the Git library shallow cloning control device 50 described in the embodiment three of the present application, and a network attached storage device 60 in communication connection with the Git library shallow cloning control device, and the network attached storage device 60 stores a plurality of dependency configuration parameters of Git code libraries, when the Git library shallow cloning control device 50 performs shallow cloning control on any Git code library, the Git library shallow cloning control device 50 completes the shallow cloning operation on the Git code library according to the Git library shallow cloning control method described in the embodiment one or the embodiment two of the present application and based on the dependency configuration parameters of the Git code library; or Please refer to Figure 10 , Figure 10 is a structural schematic diagram of another Git library shallow cloning control system disclosed by the embodiment of the present application. As shown in Figure 10 , the Git library shallow cloning control system at least includes the electronic device 40 described in the embodiment four of the present application, and a network attached storage device 60 in communication connection with the electronic device, and the network attached storage device 40 stores a plurality of dependency configuration parameters of Git code libraries, when the electronic device 40 performs shallow cloning control on any Git code library, the electronic device 40 completes the shallow cloning operation on the Git code library according to the Git library shallow cloning control method described in the embodiment one or the embodiment two of the present application and based on the dependency configuration parameters of the Git code library.
[0086] Embodiment six The embodiment of the present application discloses a computer storage medium, which stores computer instructions, when the computer instructions are invoked, part or all of the steps of the Git library shallow cloning control method described in the embodiment one or the embodiment two of the present application are executed.
[0087] Example Seven The embodiment of the present application discloses a computer program product, which comprises a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps in the method for controlling shallow cloning of a Git library described in the embodiment one or the embodiment two.
[0088] The above-described apparatus embodiments are only schematic, wherein the modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, i.e., may be located in one place or distributed over multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment scheme. Those skilled in the art can understand and implement without creative labor.
[0089] Through the above specific description of the embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of software and the necessary general hardware platform, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, including a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, a magnetic disk storage, a magnetic tape storage, or any other medium that can be used to carry or store data.
[0090] It should be pointed out finally that the above-described embodiments only disclose the preferred embodiments of the present application and are only used for illustrating the technical solutions of the present application but not for limiting the same. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified or some technical features thereof can be replaced equivalently, 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 application.
Claims
1. A method for controlling shallow cloning of a Git library, characterized in that, The method is applied to an electronic device with an application installed, and the electronic device is communicatively connected to a network-attached storage device (NAT). The electronic device accesses the NAT through the application. The method is used to perform shallow cloning control on any Git repository in the electronic device or the NAT. The method includes: The system performs preset processing operations on the dependency configuration parameters set by the user in the configuration file of a pre-determined Git dependency repository, and obtains the parameter processing results. The dependency configuration parameters include one or more combinations of Git repository address parameters, branch parameters, and shallow parameters. If the user specifies the branch parameter, the target shallow clone strategy for the Git dependency library is determined based on the parameter processing result and the preset multi-dimensional joint conditions, and the shallow clone operation corresponding to the target shallow clone strategy is executed on the Git dependency library. The target shallow clone strategy includes a forced shallow clone strategy or a default shallow clone strategy. If the user does not specify the branch parameter, then the shallow clone operation corresponding to the default shallow clone strategy is performed on the Git dependency library.
2. The shallow clone control method for Git libraries according to claim 1, characterized in that, The process of performing preset processing operations on the dependency configuration parameters set by the user in the configuration file of a pre-determined Git dependency repository, and obtaining the parameter processing results, includes: Obtain the dependency configuration parameters set by the user in the configuration file of a pre-determined Git dependency repository, and parse the dependency configuration parameters to obtain at least one key parameter of the configuration file; Based on a preset security verification mechanism, a first security verification operation is performed on all the key parameters. When the verification is successful, all the key parameters and the security-fixed parameters obtained after the first security verification operation are taken as a complete parameter set. The complete parameter set is then optimized and reorganized to form a dual configuration object containing all the original key parameters and the security-fixed parameters obtained after the first security verification operation, which serves as the parameter processing result.
3. The shallow clone control method for Git libraries according to claim 1 or 2, characterized in that, The step of determining the target shallow cloning strategy for the Git dependency library based on the parameter processing results and preset multi-dimensional joint conditions includes: Based on the parameter processing results and the preset multi-dimensional joint conditions, determine whether the Git dependency library meets the preset forced shallow clone startup conditions, and obtain the judgment result; When the determination result is that the Git dependency library meets the forced shallow clone startup condition, the forced shallow clone strategy is determined as the target shallow clone strategy to be executed on the Git dependency library. When the determination result is that the Git dependency library does not meet the forced shallow clone startup condition, the default shallow clone strategy is determined as the target shallow clone strategy to be executed on the Git dependency library. And, the shallow cloning operation corresponding to the target shallow cloning strategy performed on the Git dependency library includes: Based on the parameter processing results, determine the git command parameters for the Git dependency library under the target shallow clone strategy; Based on a preset security verification mechanism, a second security verification operation is performed on the git command parameters; and when the verification is successful, the shallow clone operation corresponding to the target shallow clone strategy is performed on the Git dependency library by running the git command parameters corresponding to the target shallow clone strategy.
4. The shallow clone control method for Git libraries according to claim 3, characterized in that, The step of determining whether the Git dependency library meets the preset forced shallow clone startup conditions based on the parameter processing results and preset multi-dimensional joint conditions, and obtaining the determination result, includes: Identify the Git dependency library, obtain the identification information of the Git dependency library, and determine whether the Git dependency library belongs to the preset target library based on the identification information of the Git dependency library, which is denoted as the first condition. The target library is the internal code library of the user's company. Based on the Git repository address parameter included in the parameter processing result, determine whether the Git repository address parameter of the Git dependent library belongs to the domain name list of the target library, and record it as the second condition; Based on the shallow parameter included in the parameter processing result, determine whether the configuration file of the Git dependency library specifies the shallow parameter as a parameter for shallow cloning, denoted as the third condition. The shallow parameter includes parameters for shallow cloning, or parameters for not performing shallow cloning. Specifically, when the first condition, the second condition, and the third condition are all satisfied, the judgment result is determined to be that the Git dependency library meets the preset forced shallow clone startup condition; when at least one of the first condition, the second condition, and the third condition is not satisfied, the judgment result is determined to be that the Git dependency library does not meet the preset forced shallow clone startup condition.
5. The shallow clone control method for Git libraries according to claim 3, characterized in that, The step of determining the git command parameters for the Git dependency library under the target shallow clone strategy based on the parameter processing results includes: When the target shallow clone strategy is the default shallow clone strategy, construct the parameter list of the git clone command as the git command parameters that Git depends on; When the target shallow clone strategy is the forced shallow clone strategy, construct the parameter list of the git clone command; and according to the parameter processing result, add the pre-set target parameters to the parameter list to obtain the updated parameter list; determine the updated parameter list as the git command parameters that Git depends on.
6. The shallow clone control method for Git libraries according to claim 5, characterized in that, When the user specifies the branch parameter, the parameter processing result also includes the current hash value corresponding to the branch parameter; The current hash value is determined in the following way: Based on the first preset regular expression, the current hash value of the branch indicated by the branch parameter is determined.
7. The shallow clone control method for a Git repository according to any one of claims 1, 2, 4, 5, and 6, characterized in that, The method further includes: The execution result of the shallow cloning operation is detected. The execution result is used to represent the cloning result of the target shallow cloning strategy, and the cloning result includes the result of shallow cloning success or shallow cloning failure. When the execution result indicates that the shallow clone has failed, based on the preset error rollback mechanism, the error type of the git command parameter is identified by the second preset regular expression; and the exception handling strategy corresponding to the error type is determined according to the error type of the git command parameter, and the exception handling operation for the error type is executed according to the exception handling strategy.
8. A shallow cloning control device for a Git repository, characterized in that, The device is applied to an electronic device with an application installed, and the electronic device is communicatively connected to a network-attached storage device (NAT). The electronic device accesses the NAT through the application. The device is used to perform shallow cloning control on any Git repository in the electronic device or the NAT. The device includes: The parameter preprocessing module is used to perform preset processing operations on the dependency configuration parameters set by the user in the configuration file of the pre-determined Git dependency repository, and obtain the parameter processing result. The dependency configuration parameters include one or more combinations of Git code repository address parameters, branch parameters and shallow parameters. The strategy decision module is used to determine the target shallow clone strategy for the Git dependency library based on the parameter processing result and preset multi-dimensional joint conditions if the user specifies the branch parameter; and to perform a shallow clone operation corresponding to the target shallow clone strategy on the Git dependency library. The target shallow clone strategy includes a forced shallow clone strategy or a default shallow clone strategy. The strategy decision module is further configured to perform a shallow clone operation corresponding to the default shallow clone strategy on the Git dependency library if the user does not specify the branch parameter.
9. An electronic device, characterized in that, The electronic device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the shallow cloning control method of the Git library as described in any one of claims 1-7.
10. A shallow clone control system for a Git repository, the system comprising at least a shallow clone control device for a Git repository as described in claim 8, and a network-attached storage device communicatively connected to the shallow clone control device for the Git repository, wherein the network-attached storage device stores dependency configuration parameters for a plurality of Git code repositories, and when the shallow clone control device for the Git repository performs shallow clone control on any of the Git code repositories, the shallow clone control device for the Git repository completes the shallow clone operation for the Git code repository according to the shallow clone control method for a Git repository as described in any one of claims 1-7 and based on the dependency configuration parameters of the Git code repository; or, The system includes at least the electronic device as described in claim 9, and a network-attached storage device communicatively connected to the electronic device, wherein the network-attached storage device stores dependency configuration parameters for multiple Git code repositories. When the electronic device performs shallow cloning control on any of the Git code repositories, the electronic device completes the shallow cloning operation on the Git code repository according to the shallow cloning control method for Git repositories as described in any one of claims 1-7 and based on the dependency configuration parameters of the Git code repository.
11. A computer storage medium, characterized in that, The computer storage medium stores computer instructions, which, when invoked, are used to execute the shallow cloning control method for the Git library as described in any one of claims 1-7.