Code repository management method and device, computer device and storage medium
By generating environment configuration files in the code repository that match the runtime environment, the number of code branches for each version is reduced, solving the management complexity problem of multiple versions and multiple environments, improving the management efficiency of the code repository and reducing maintenance costs.
Patent Information
- Application Number
- CN202010999270.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-22
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2040-09-22
AI Technical Summary
In scenarios with multiple versions and multiple runtime environments, the code repository needs to store N code branches, which is equivalent to the number of runtime environments N, leading to complex management and low efficiency.
By identifying the similarities and differences between multiple environment code branches of the target code, an environment configuration file matching the runtime environment is generated. The similarities between the multiple environment code branches are then used as the basis to generate a version code branch corresponding to the target code.
In a multi-runtime environment, the code repository only needs to store one version of the code branch for each version, which simplifies management, improves the management efficiency of the code repository, and reduces maintenance costs.
Smart Images

Figure CN114253595B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a code repository management method and device, computer equipment and storage medium. BACKGROUND
[0002] The code repository is a storage mechanism of software such as application code, and is commonly used for code version management and code change tracking. The code repository, such as the git repository, provides a branch function, and by using code branches, work can be separated from the development main line to avoid affecting the development main line.
[0003] In different stages of software development, the software needs to be deployed in different running environments, which may include development environment, test environment, pre-release environment and formal environment, for example. The code repository needs to store each software version of the software in multiple running environments. In related technologies, in the scenario of multiple versions and multiple running environments, the code repository needs to store N code branches corresponding to the number N of running environments for each version, and the increase of software versions causes the number of code branches to increase by a linear multiple of the number of running environments, resulting in complex management of the code repository and reducing the management efficiency of the code repository for each version of code. SUMMARY
[0004] In order to solve the problems of the prior art, the embodiments of the present application provide a code repository management method and device, computer equipment and storage medium. The technical solution is as follows:
[0005] On the one hand, a code repository management method is provided, which comprises:
[0006] Obtaining target code of a first version, and determining a plurality of environment code branches corresponding to the target code of the first version; the first version is any version of the target code in the code repository, and the plurality of environment code branches correspond to a plurality of running environments in which the target code is run;
[0007] Determining the same content between the plurality of environment code branches and the difference content in each environment code branch, wherein the difference content is the content in the environment code branch that is different from other environment code branches;
[0008] Generating an environment configuration file matched with the running environment of each environment code branch according to the difference content of each environment code branch, to obtain a plurality of environment configuration files corresponding to the plurality of running environments;
[0009] Taking the same content between the plurality of environment code branches as the basic content, and generating a version code branch corresponding to the target code of the first version according to the basic content and the plurality of environment configuration files.
[0010] In another aspect, a code repository management apparatus is provided, the apparatus comprising:
[0011] an environment branch determination module configured to obtain a first version of target code and determine a plurality of environment code branches corresponding to the first version of target code, the first version being any version of the target code in a code repository, the plurality of environment code branches corresponding to a plurality of running environments in which the target code is run;
[0012] a content determination module configured to determine identical content among the plurality of environment code branches and difference content in each environment code branch, the difference content being content in the environment code branch that is different from other environment code branches;
[0013] a configuration generation module configured to generate an environment configuration file matching a running environment of the environment code branch according to the difference content in each environment code branch, to obtain a plurality of environment configuration files corresponding to the plurality of running environments;
[0014] a version branch generation module configured to take the identical content among the plurality of environment code branches as base content, and generate a version code branch corresponding to the first version of target code according to the base content and the plurality of environment configuration files.
[0015] In one possible implementation, the configuration generation module comprises:
[0016] an extraction module configured to extract the difference content for the difference content in each environment code branch;
[0017] a type determination module configured to determine a difference type of the difference content;
[0018] a configuration operation determination module configured to determine a target configuration operation matching the difference type in preset configuration operations;
[0019] a first configuration generation submodule configured to generate an environment configuration file matching a running environment of the environment code branch according to the difference content and the target configuration operation.
[0020] In one possible implementation, the first configuration generation submodule comprises:
[0021] a position information determination module configured to determine position information of the difference content in the environment code branch;
[0022] a second configuration generation submodule configured to generate an environment configuration file matching a running environment of the environment code branch according to the difference content, the position information of the difference content, and the target configuration operation.
[0023] In a possible implementation, the apparatus further includes:
[0024] a first determining module configured to determine a first runtime environment from the plurality of runtime environments;
[0025] a first obtaining module configured to obtain a target environment configuration file matched with the first runtime environment from a version code branch corresponding to the target code of the first version;
[0026] a first generating module configured to generate a target environment code branch matched with the first runtime environment according to the target environment configuration file and the base content in the version code branch;
[0027] a compiling module configured to compile the target environment code branch to obtain an executable file matched with the first runtime environment.
[0028] In a possible implementation, the first generating module includes:
[0029] a second obtaining module configured to obtain target difference content and a target configuration operation in the target environment configuration file;
[0030] a first generating submodule configured to perform target configuration on the base content in the version code branch through the target configuration operation according to the target difference content, to generate a target environment code branch matched with the first runtime environment.
[0031] In a possible implementation, the first generating submodule includes:
[0032] a third obtaining module configured to obtain position information corresponding to the target difference content from the target environment configuration file;
[0033] a position determining module configured to determine a target position of the target difference content in the base content in the version code branch according to the position information corresponding to the target difference content;
[0034] a second generating submodule configured to perform target configuration on the target difference content at the target position in the base content through the target configuration operation, to generate a target environment code branch matched with the first runtime environment.
[0035] In another aspect, a computer device is provided, including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the above-mentioned code repository management method.
[0036] In another aspect, a computer-readable storage medium is provided, the storage medium storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the code repository management method as described above.
[0037] In another aspect, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided in the various optional implementations described above.
[0038] The embodiments of the present application determine the same content between the plurality of environment code branches corresponding to any version of the target code in the code repository and the differential content in each environment code branch, and generate an environment configuration file matching the running environment of each environment code branch according to the differential content in each environment code branch, and further generate a version code branch corresponding to the target code of the version according to the same content between the plurality of environment code branches and the plurality of environment configuration files. Through the above technical solutions, in the scenario of multiple running environments, the code repository only needs to store one version code branch for each version of the software, and the code repository only needs to store one version code branch for each newly added version of the software. Compared with the related art in which each version needs to store N code branches corresponding to the number N of running environments, the embodiments of the present application reduce the number of code branches in the repository, thereby simplifying the management of the code repository and improving the management efficiency of the code repository for each version of code. BRIEF DESCRIPTION OF DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. 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 effort.
[0040] Figure 1 is a schematic diagram of an implementation environment provided by the embodiments of the present application;
[0041] Figure 2 is a flowchart of a code repository management method provided by the embodiments of the present application;
[0042] Figure 3 is an optional flowchart of generating an environment configuration file provided by the embodiments of the present application;
[0043] Figure 4is an optional example of generating an environment configuration file provided by the embodiment of the present application;
[0044] Figure 5 is a flow diagram of another code repository management method provided by the embodiment of the present application;
[0045] Figure 6 is an optional example of compiling executable files required by two running environments based on version code branches provided by the embodiment of the present application;
[0046] Figure 7 is a structural diagram of a code repository management device provided by the embodiment of the present application;
[0047] Figure 8 is a hardware structure block diagram of a computer device provided by the embodiment of the present application. DETAILED DESCRIPTION
[0048] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0049] It should be noted that 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 similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or server including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0050] In the related art, the storage of the code repository for multiple versions of a software in multiple running environments is generally to first establish a code branch corresponding to each running environment for different running environments, and then establish multiple version code branches for each running environment. For example, assuming that there are currently 4 running environments, and a software A has a 418 version, the code repository needs to store a 418 version code branch in each running environment, so that 4 418 version code branches need to be stored for the 418 version of the software A. If the software A increases a 518 version, the code repository needs to store a 518 version code branch in each running environment, so that 4 518 version code branches need to be stored for the 518 version of the software A. If the software A increases a 618 version, the code repository needs to store a 618 version code branch in each running environment, so that 4 618 version code branches need to be stored for the 618 version of the software A. At this time, the code repository needs to manage 12 (4x3=12) code branches for the software A, and the total number of the code branches changes with the number of running environments and the number of versions, that is, the number of code branches corresponding to each software in the code repository is simultaneously affected by the two dimensions of the number of running environments and the number of versions in the related art, so that it is not only more complex to manage, which reduces the management efficiency of the code repository for each version code, but also the maintenance cost is very high, and the management cost of the code repository will increase by a linear multiple of the number of running environments.
[0051] Therefore, the embodiment of the present application provides a code repository management method, which modifies the two-dimensional change of the number of running environments and the number of versions into one-dimensional change based on the version, that is, each version of the software in the code repository only stores a version code branch. Compared with the related art, each increase of a version needs to store N code branches corresponding to the number of running environments, the embodiment of the present application not only simplifies the management of the code repository, improves the management efficiency of the code repository for each version code, but also greatly reduces the maintenance cost of the code repository.
[0052] Please refer to Figure 1 , which shows an implementation environment schematic diagram provided by the embodiment of the present application, which can include a terminal 110 and a server 120.
[0053] The terminal 110 can be a smartphone, a tablet computer, a notebook computer, a desktop computer, and other computer devices. The server 120 can be a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system, and can also be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and basic cloud computing services such as big data and artificial intelligence platforms. The terminal 110 and the server 120 can be connected directly or indirectly through wired or wireless communication, which is not limited in the present application.
[0054] The server 120 maintains a code repository for code version management, which can be but is not limited to a Git repository. Git is an open source distributed version control system for agile and efficient handling of any large or small project. The code repository is provided with a branch function, and by using code branches, work can be separated from the development main line to avoid affecting the development main line, that is, the code branches are different code lines corresponding to the same software.
[0055] The terminal 110 can install a client provided by the server 120, such as Git, and the terminal 110 can implement functions such as data transmission and message interaction through the client. The user corresponding to the terminal 110 can be a developer in a development team, who can create a code branch corresponding to the current stage through the client in the terminal 110, and push the code branch to the code repository maintained by the server 120. In actual applications, the development of software needs to go through different stages, and the environment corresponding to each stage, that is, the running environment of the software, is also different, which can generally include a development environment, a test environment, a pre-release environment, and a formal environment.
[0056] Referring to Figure 2 , a flowchart of a code repository management method provided by an embodiment of the present application is shown. The method can be applied to the server in Figure 1 . It should be noted that the present specification provides method operation steps as described in the embodiments or flowcharts, but more or fewer operation steps can be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one of the many execution orders, and does not represent the only execution order. In actual system or product execution, the method order shown in the embodiments or the drawings can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment). Specifically, as shown in Figure 2 , the method can include:
[0057] S201, obtaining a target code of a first version, and determining a plurality of environment code branches corresponding to the target code of the first version.
[0058] The first version is any version of the target code in the code repository, and the plurality of environment code branches correspond to a plurality of running environments in which the target code runs.
[0059] The target code can be any application code stored in the code repository. There is at least one version of the target code in the code repository, and any version of the target code can be obtained from the code repository as the first version. Each version of the target code has a code branch suitable for a different development stage, and the running environment corresponding to different development stages is generally different. In practical applications, the running environment corresponding to each development stage is generally a development environment, a test environment, a pre-release environment, and a formal environment, that is, each version of the target code in the code repository has a code branch suitable for different running environments.
[0060] In the embodiments of the present application, the code branch of the target code suitable for a certain running environment is referred to as an environment code branch corresponding to the running environment. For example, when the running environment includes a development environment, a test environment, a pre-release environment, and a formal environment, each version of the target code has an environment code branch corresponding to the above-mentioned development environment, test environment, pre-release environment, and formal environment, respectively.
[0061] It can be understood that in practical applications, the running environment for running the target code is not limited to the above-mentioned development environment, test environment, pre-release environment, and formal environment, and more or fewer running environments can be set according to actual needs, and the present application does not make specific limitations thereto.
[0062] S203, determine the same content among the plurality of environment code branches and the difference content in each environment code branch, the difference content being the content in the environment code branch different from other environment code branches.
[0063] In practical applications, the target code of the same version corresponding to different running environments in the code repository generally includes two parts, one part is the content changed according to the running environment, and the other part is the content not changed with the running environment. Taking the target code as an APP (Application, application code) code as an example, the keys, sub-projects that need to be included, and background addresses accessed under different running environments are all inconsistent, then the content in each environment code branch that changes according to the running environment is referred to as the difference content, and the content not changed with the running environment is referred to as the same content.
[0064] The difference content in the environment code branch can include, but is not limited to, code, pictures, layout files, audio files, signature files, and the like. Similarly, the same content between the multiple environment code branches can also include, but is not limited to, code, pictures, layout files, audio files, signature files, and the like.
[0065] In a specific implementation, the multiple environment code branches corresponding to the target code of the first version can be compared, so that the content different from other environment code branches in each environment code branch is found, and the different content is the difference content in the environment code branch.
[0066] S205, generating an environment configuration file matched with the running environment of each environment code branch according to the difference content of the environment code branch, to obtain multiple environment configuration files corresponding to the multiple running environments.
[0067] Specifically, step S205 can adopt the method shown in Figure 3 when executed, Figure 3 The flowchart shown in FIG. 3 is an optional method for generating an environment configuration file matched with the running environment of each environment code branch according to the difference content of the environment code branch, provided by the embodiment of the present application, and can include the following steps. Figure 3
[0068] S301, extracting the difference content in each environment code branch.
[0069] Taking the picture 1 as an example, the picture 1 can be extracted.
[0070] S303, determining the difference type of the difference content.
[0071] The difference type can be determined according to the content form of the difference content in the environment branch code, and the difference type can include pictures, audio and video, code, and the like. Specifically, the difference type can be determined according to the content form involved in the actual application. For example, in the example above, the difference content is the picture 1, and the difference type corresponding to the difference content is the picture.
[0072] S305, determining a target configuration operation matched with the difference type in the preset configuration operation.
[0073] In the embodiment of the present application, the configuration operation matched with each difference type is pre-configured for the possible difference types, and the configuration operation is used to represent the configuration action to be performed under the corresponding difference type. For example, when the difference type is a picture, the configuration operation of copying the difference content to the corresponding position can be set for the difference type, that is, the mapping relationship between the preset difference type and the preset configuration operation is pre-set, wherein the preset configuration operation can include but is not limited to copying the difference content, deleting the difference content, and the like, and more configuration operations can be set according to the actual application, which is not limited in the present application.
[0074] In the specific implementation, the target mapping relationship matched with the difference type in the pre-set configuration operation can be searched, and then the configuration operation in the target mapping relationship is taken as the target configuration operation.
[0075] S307, generating an environment configuration file matched with the running environment of the environment code branch according to the difference content and the target configuration operation.
[0076] In the actual application, when the environment configuration file is generated, the position information of the difference content in the corresponding environment branch code can also be determined, and then the environment configuration file matched with the running environment of the environment branch code is generated according to the difference content, the position information corresponding to the difference content and the target configuration operation.
[0077] The position information of the difference content can be represented by the characters before and after the difference content, for example, the character before the difference content is character "a", and the character after the difference content is character "b", and then the position information of the difference content can be represented as {a, b}. Of course, other ways of representing the position information can also be used, such as the character number difference between the first character, which is not limited in the present application.
[0078] In the embodiment of the present application, the configuration operation matched with each difference type is pre-configured for the possible difference types, and the configuration operation is used to represent the configuration action to be performed under the corresponding difference type. For example, when the difference type is a picture, the configuration operation of copying the difference content to the corresponding position can be set for the difference type, that is, the mapping relationship between the preset difference type and the preset configuration operation is pre-set, wherein the preset configuration operation can include but is not limited to copying the difference content, deleting the difference content, and the like, and more configuration operations can be set according to the actual application, which is not limited in the present application. Figure 4 For example, the two running environments included in the environment code branch dev and the environment code branch sit are determined, and the same content in the environment code branch dev and the environment code branch sit is extracted, wherein the difference content in the environment code branch dev is used to generate the environment configuration file Dev corresponding to the dev environment, and the difference content in the environment code branch sit is used to generate the environment configuration file Sit.
[0079] S207, taking the same content between the multiple environment code branches as the basic content, and generating the version code branch corresponding to the target code of the first version according to the basic content and the multiple environment configuration files.
[0080] In the embodiment of the present application, the same content between the plurality of environment code branches corresponding to the first version of the target code is taken as the basic content, and the version code branch of the first version of the target code in the code repository is generated according to the basic content and the plurality of environment configuration files corresponding to each running environment in the foregoing step S205, so that only one version code branch corresponding to the first version of the target code is stored in the code repository.
[0081] Based on the foregoing technical solution, the code repository only stores one version code branch corresponding to any version of the target code under the plurality of running environments, and each version code branch includes corresponding basic content and a plurality of environment configuration files corresponding to each running environment. Therefore, when there are N running environments and n versions of the target code, the code repository only needs to manage n version code branches for the target code. Compared with the prior art which needs to manage N*n code branches, the embodiment of the present application only needs to consider the change of one dimension of version, greatly reduces the management complexity of the code repository, simplifies the management of the code repository, improves the management efficiency of the code repository for each version code, and reduces the maintenance cost of the code repository.
[0082] Please refer to Figure 5 which is a flowchart of another code repository management method provided by the embodiment of the present application. The method is used after the foregoing Figure 2 The step S207 shown in the foregoing method can further include:
[0083] S501, determining a first running environment in the plurality of running environments.
[0084] The first running environment is a running environment in which the first version of the target code is to be deployed and run, and can be any running environment in the plurality of running environments. For example, the plurality of running environments include a development environment, a test environment, a pre-release environment and a formal environment. At present, the a version of the application program code needs to be deployed and run in the test environment, so the first running environment is the test environment. If the a version of the application program code needs to be deployed and run in the pre-release environment, the first running environment is the pre-release environment.
[0085] S503, obtaining a target environment configuration file matched with the first running environment from the version code branch corresponding to the first version of the target code.
[0086] Since the first version of the target code corresponds to the version code branch including the environment configuration file corresponding to each running environment, the environment configuration file matched with the first running environment can be obtained according to the matching relationship between the running environment and the environment configuration file. For example, the plurality of running environments include a development environment, a test environment, a pre-release environment and a formal environment, and the first running environment is the test environment. Then, the target environment configuration file can be obtained from the version code branch corresponding to the first version of the target code, which corresponds to the test environment.
[0087] S505, generating a target environment code branch matched with the first running environment according to the target environment configuration file and the basic content in the version code branch.
[0088] In a specific implementation, the target difference content and the target configuration operation in the target environment configuration file can be obtained; and the target configuration operation is used to perform target configuration on the basic content in the version code branch according to the target difference content, so as to generate the target environment code branch matched with the first running environment.
[0089] As a possible implementation, when the target environment code branch matched with the first running environment is generated by performing target configuration on the basic content in the version code branch according to the target difference content through the target configuration operation, the position information corresponding to the target difference content can be obtained from the target environment configuration file first, and then the target position of the target difference content in the basic content of the version code branch is determined according to the position information corresponding to the target difference content, and the target difference content is configured at the target position in the basic content through the target configuration operation, so as to generate the target environment code branch matched with the first running environment.
[0090] The target difference content can be integrated into the basic content of the version code branch through the target configuration operation, so as to form a complete code branch, and the complete code branch is adapted to the running environment in which the target code of the first version is to be deployed and run.
[0091] S507, compiling the target environment code branch to obtain an executable file matched with the first running environment.
[0092] In practical applications, the above steps S501 to S505 can be regarded as pre-compilation processing, that is, the environment configuration logic for realizing the functions of the above steps S501 to S505 can be added before the compilation logic of the compilation script.
[0093] Still taking the two running environments dev (development environment) and sit (test environment) as an example, as shown in Table 1, the version code branch corresponding to the first version of the target code includes the basic content and the target difference content. Figure 6As shown, a version code branch of an application code of v1.0 version is indicated in a dashed box, the version code branch includes a piece of base content x and two environment configuration files, i.e., dev configuration and sit configuration. The pre-processing environment configuration logic for implementing the above steps S501 to S505 is included in the compiling script, in the dev compiling process, the base content x in the version code branch is first environment configured according to the dev configuration, and then the dev environment code branch after environment configuration is compiled to obtain an installation package Dev.apk adapted to the dev environment; similarly, in the sit compiling process, the base content x in the version code branch is first environment configured according to the sit configuration, and then the sit environment code branch after environment configuration is compiled to obtain an installation package Sit.apk adapted to the sit environment.
[0094] As can be seen from the above technical solutions of the embodiments of the present application, for any version of target code, the embodiments of the present application can compile executable files, i.e., installation packages, required by multiple running environments based on a version code branch corresponding to the version, thereby improving the management efficiency of the code repository and the compiling efficiency of the executable files.
[0095] Corresponding to the code repository management method provided by the above several embodiments, the embodiments of the present application also provide a code repository management device. Since the code repository management device provided by the embodiments of the present application corresponds to the code repository management method provided by the above several embodiments, the implementation manners of the foregoing code repository management method are also applicable to the code repository management device provided by the present embodiments, which will not be described in detail in the present embodiments.
[0096] Please refer to Figure 7 which shows a structure schematic diagram of a code repository management device provided by the embodiments of the present application. The device has the function of implementing the code repository management method in the above method embodiments. The function can be implemented by hardware, or the corresponding software can be executed by hardware. As shown in the figure, Figure 7 The device can include:
[0097] The environment branch determination module 710 is configured to acquire target code of a first version, and determine a plurality of environment code branches corresponding to the target code of the first version. The first version is any version of the target code in the code repository, and the plurality of environment code branches correspond to a plurality of running environments running the target code.
[0098] The content determination module 720 is configured to determine the same content among the plurality of environment code branches and the difference content in each environment code branch. The difference content is the content in the environment code branch different from other environment code branches.
[0099] The configuration generation module 730 is configured to generate an environment configuration file matched with a running environment of each environment code branch according to the difference content of the environment code branch, to obtain a plurality of environment configuration files corresponding to the plurality of running environments.
[0100] The version branch generation module 740 is configured to take the same content between the plurality of environment code branches as base content, and generate a version code branch corresponding to the target code of the first version according to the base content and the plurality of environment configuration files.
[0101] In a possible implementation, the configuration generation module 730 can include:
[0102] The extraction module is configured to extract the difference content in each environment code branch;
[0103] The type determination module is configured to determine a difference type of the difference content;
[0104] The configuration operation determination module is configured to determine a target configuration operation matched with the difference type in preset configuration operations;
[0105] The first configuration generation submodule is configured to generate an environment configuration file matched with a running environment of the environment code branch according to the difference content and the target configuration operation.
[0106] In a possible implementation, the first configuration generation submodule can include:
[0107] The position information determination module is configured to determine position information of the difference content in the environment code branch;
[0108] The second configuration generation submodule is configured to generate an environment configuration file matched with a running environment of the environment code branch according to the difference content, the position information corresponding to the difference content, and the target configuration operation.
[0109] In a possible implementation, the apparatus can further include:
[0110] The first determination module is configured to determine a first running environment in the plurality of running environments;
[0111] The first acquisition module is configured to acquire a target environment configuration file matched with the first running environment from a version code branch corresponding to the target code of the first version;
[0112] The first generation module is configured to generate a target environment code branch matched with the first running environment according to the target environment configuration file and the base content in the version code branch;
[0113] The compiling module is configured to compile the target environment code branch to obtain an executable file matched with the first running environment.
[0114] In a possible implementation, the first generating module can include:
[0115] The second obtaining module is configured to obtain target difference content and a target configuration operation in the target environment configuration file.
[0116] The first generating submodule is configured to perform target configuration on the base content in the version code branch by using the target configuration operation according to the target difference content, to generate a target environment code branch matched with the first running environment.
[0117] In a possible implementation, the first generating submodule can include:
[0118] The third obtaining module is configured to obtain position information corresponding to the target difference content from the target environment configuration file.
[0119] The position determining module is configured to determine a target position of the target difference content in the base content of the version code branch according to the position information corresponding to the target difference content.
[0120] The second generating submodule is configured to perform target configuration on the target difference content at the target position in the base content by using the target configuration operation, to generate a target environment code branch matched with the first running environment.
[0121] It should be noted that the apparatus provided in the above embodiments, when realizing its functions, is only exemplified by the above division of functional modules, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is described in the method embodiments, which will not be described here.
[0122] The code repository management device of this invention, for any version of target code in the code repository, determines the common content among multiple environment code branches corresponding to that version and the differences in each environment code branch. Based on the differences in each environment code branch, it generates an environment configuration file matching the runtime environment of that environment code branch. Then, based on the common content among the multiple environment code branches and the multiple environment configuration files, it generates a version code branch corresponding to the target code of that version. Through this technical solution, in a multi-runtime environment scenario, the code repository only needs to store one version code branch for each version of the software. Each time a new software version is added, the code repository only needs to add one version code branch for that software version. Compared to related technologies where each version needs to store N code branches equivalent to the number of runtime environments N, this invention reduces the number of code branches in the repository, thereby simplifying code repository management, improving the management efficiency of the code repository for each version of code, and significantly reducing the maintenance cost of the code repository.
[0123] This invention provides a computer device including a processor and a memory. The memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the code repository management method provided in the above method embodiments.
[0124] Memory can be used to store software programs and modules. The processor executes various functional applications and manages code repositories by running the software programs and modules stored in the memory. Memory can primarily include a program storage area and a data storage area. The program storage area can store the operating system, applications required for functionality, etc.; the data storage area can store data created based on the use of the device, etc. Furthermore, memory can include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory may also include a memory controller to provide the processor with access to the memory.
[0125] The method embodiments provided in this invention can be executed in a computer terminal, server or similar computing device, that is, the computer device mentioned above may include a computer terminal, server or similar computing device. Figure 8 This is a hardware structure block diagram of a computer device for running a code repository management method provided in an embodiment of the present invention, such as... Figure 8 As shown, the internal structure of this computer device may include, but is not limited to, a processor, a network interface, and a memory. The processor, network interface, and memory within the computer device can be connected via a bus or other means, as illustrated in the embodiments of this specification. Figure 8For example, the connection by the bus is taken as an example.
[0126] The processor (or CPU (Central Processing Unit)) is the computing core and control core of the computer device. The network interface can optionally include a standard wired interface, a wireless interface (such as WI-FI, a mobile communication interface, etc.). The memory is a memory device in the computer device, used to store programs and data. It can be understood that the memory here can be a high-speed RAM memory device, or a non-volatile memory, for example, at least one disk storage device; optionally, it can also be at least one storage device located away from the aforementioned processor. The memory provides a storage space that stores the operating system of the electronic device, which can include but is not limited to: a Windows system (an operating system), a Linux (an operating system), an Android (an operating system) system, an IOS (an operating system) system, etc., and the present application does not limit this; and in the storage space, one or more instructions suitable for being loaded and executed by the processor are also stored, which can be one or more computer programs (including program codes). In the embodiment of the present application, the processor loads and executes one or more instructions stored in the memory to implement the code repository management method provided by the above-mentioned method embodiment.
[0127] The embodiment of the present application also provides a computer readable storage medium which can be arranged in a computer device to save at least one instruction or at least one program related to a code repository management method, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the code repository management method provided by the above-mentioned method embodiment.
[0128] The embodiment of the present application also provides a computer program product or a computer program, which includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the computer device execute the method provided in the various optional implementation manners.
[0129] Optionally, in the present embodiment, the storage medium can include but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0130] It should be noted that the above-mentioned embodiments of the present application are merely intended to describe the present application and are not intended to limit the present application. The above-mentioned embodiments of the present application are described in a progressive manner, and the same or similar parts among the embodiments can be mutually referred to. Each embodiment focuses on the difference from other embodiments. In particular, the device embodiments are described simply because they are basically similar to the method embodiments, and the relevant parts can be referred to the description of the method embodiments.
[0131] The embodiments in the present specification are described in a progressive manner, and the same or similar parts among the embodiments can be mutually referred to. Each embodiment focuses on the difference from other embodiments. In particular, the device embodiments are described simply because they are basically similar to the method embodiments, and the relevant parts can be referred to the description of the method embodiments.
[0132] A person of ordinary skill in the art can understand that all or part of the above-mentioned embodiments can be completed by hardware, or a program instructing relevant hardware, and the program can be stored in a computer readable storage medium, such as a read-only memory, a magnetic disk or an optical disk.
[0133] The above-mentioned embodiments are merely preferred embodiments of the present application, and are not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A code repository management method characterized by, The method comprises: acquiring a first version of target code, determining a plurality of environment code branches corresponding to the first version of target code; the first version is any version of the target code in a code repository, and the plurality of environment code branches correspond to a plurality of running environments running the target code; determining the same content between the plurality of environment code branches and the difference content in each environment code branch, the difference content being the content different from other environment code branches in the environment code branch; for the difference content in each environment code branch, extracting the difference content; determining the difference type of the difference content; determining the target configuration operation in the preset configuration operation matched with the difference type; according to the difference content and the target configuration operation, generating an environment configuration file matched with the running environment of the environment code branch, obtaining a plurality of environment configuration files corresponding to the plurality of running environments; taking the same content between the plurality of environment code branches as the basic content, and generating a version code branch corresponding to the first version of target code according to the basic content and the plurality of environment configuration files.
2. The code repository management method according to claim 1, characterized by, The method further comprises: determining a first running environment in the plurality of running environments; acquiring a target environment configuration file matched with the first running environment from the version code branch corresponding to the first version of target code; 3. The code repository management method according to claim 1, characterized by, generating a target environment code branch matched with the first running environment according to the target environment configuration file and the basic content in the version code branch; compiling the target environment code branch to obtain an executable file matched with the first running environment. The method further comprises: acquiring target difference content and target configuration operation in the target environment configuration file; generating a target environment code branch matched with the first running environment by performing target configuration on the basic content in the version code branch through the target configuration operation according to the target difference content.
4. The code repository management method according to claim 3, characterized by, The method further comprises: acquiring position information corresponding to the target difference content from the target environment configuration file; determining a target position of the target difference content in the basic content of the version code branch according to the position information corresponding to the target difference content.
5. The code repository management method according to claim 4, characterized by, The target configuration operation is used to target configure the target difference content at the target position in the base content, and generate a target environment code branch matched with the first running environment.
6. A code repository management apparatus characterized by comprising: The device comprises: An environment branch determination module is configured to acquire a first version of target code and determine a plurality of environment code branches corresponding to the first version of target code; the first version is any version of the target code in a code repository, and the plurality of environment code branches correspond to a plurality of running environments in which the target code is run; A content determination module is configured to determine identical content among the plurality of environment code branches and difference content in each environment code branch; the difference content is content in the environment code branch that is different from other environment code branches; A configuration generation module is configured to generate an environment configuration file matched with a running environment of the environment code branch according to the difference content in each environment code branch, and obtain a plurality of environment configuration files corresponding to the plurality of running environments; A version branch generation module is configured to take the identical content among the plurality of environment code branches as base content, and generate a version code branch corresponding to the first version of target code according to the base content and the plurality of environment configuration files; The configuration generation module comprises: An extraction module is configured to extract the difference content for the difference content in each environment code branch; A type determination module is configured to determine a difference type of the difference content; A configuration operation determination module is configured to determine a target configuration operation matched with the difference type in preset configuration operations; A first configuration generation submodule is configured to generate an environment configuration file matched with a running environment of the environment code branch according to the difference content and the target configuration operation.
7. The code repository management apparatus according to claim 6, characterized by, The first configuration generation submodule comprises: A position information determination module is configured to determine position information of the difference content in the environment code branch; A second configuration generation submodule is configured to generate an environment configuration file matched with a running environment of the environment code branch according to the difference content, the position information corresponding to the difference content, and the target configuration operation.
8. The code repository management apparatus according to claim 6, characterized by, The device further comprises: A first determination module is configured to determine a first running environment in the plurality of running environments; A first acquisition module is configured to acquire a target environment configuration file matched with the first running environment from a version code branch corresponding to the first version of target code; A first generation module is configured to generate a target environment code branch matched with the first running environment according to the target environment configuration file and the base content in the version code branch; A compiling module is configured to compile the target environment code branch to obtain an executable file matched with the first running environment.
9. The code repository management apparatus according to claim 8, characterized by, The first generation module comprises: A second acquisition module is configured to acquire target difference content and a target configuration operation in the target environment configuration file; The first generating submodule is configured to perform target configuration on the base content in the version code branch by using the target configuration operation according to the target difference content, and generate a target environment code branch matched with the first running environment.
10. The code repository management apparatus according to claim 9, wherein The first generating submodule comprises: A third acquiring module is configured to acquire position information corresponding to the target difference content from the target environment configuration file. A position determining module is configured to determine a target position of the target difference content in the base content of the version code branch according to the position information corresponding to the target difference content. A second generating submodule is configured to perform target configuration on the target difference content at the target position in the base content by using the target configuration operation, and generate a target environment code branch matched with the first running environment.
11. A computer device, comprising: A computer device comprises a processor and a memory, and the memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the warehouse management method in any one of claims 1-5.
12. A computer readable storage medium, which stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the warehouse management method in any one of claims 1-5.
13. A computer program product, which comprises computer instructions stored in a computer readable storage medium, and a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the warehouse management method in any one of claims 1-5.
Citation Information
Patent Citations
Branch code management method and device
CN108984413A
Test system and method
CN109739744A