Code repository management method and device, electronic equipment, storage medium and program product
By receiving user instructions and determining the execution scenario, the system automatically selects the target repository from multiple code repositories to perform operations, solving the problem of manually switching between multiple code repositories in existing technologies and achieving efficient code repository management.
Patent Information
- Application Number
- CN202411842963.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2044-12-12
AI Technical Summary
Existing version control tools can only operate on a single code repository, which means that when multiple code repositories are involved, users need to switch to each repository separately to perform operations, wasting time.
This paper provides a code repository management method that receives user instructions, determines operation instructions and execution scenarios, automatically selects candidate repositories from multiple code repositories, and executes operations in the target repository according to the operation instructions, supporting unified management of multiple code repositories.
Users do not need to manually switch to each code repository, which significantly saves time and improves operational and management efficiency.
Smart Images

Figure CN119781750B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of software engineering, and particularly relate to a code repository management method and device, electronic equipment, storage medium and program product. BACKGROUND
[0002] The development of the Internet brings great convenience to people's life, and also promotes the birth and development of software version management tools. A version control tool (also known as a source code management tool) is a tool software used in software engineering, which is used to manage the source code change history in the software development process. Existing version management tools, such as SVN (SubVersion) and Git, usually only support operations on a single code repository. However, an existing software development project may have multiple code repositories for storing code. When using the existing version management tools, if a user's operation involves multiple code repositories, the user needs to switch to each code repository to perform the operation, which greatly wastes the user's time. SUMMARY
[0003] Therefore, embodiments of the present application provide a code repository management method and device, electronic equipment, storage medium and program product to at least partially solve the above problems.
[0004] The embodiments of the present application provide a code repository management method, which includes: receiving a user instruction; determining an operation instruction for indicating a to-be-executed operation and an execution scenario of the to-be-executed operation according to the user instruction; determining a candidate repository for executing the to-be-executed operation from a plurality of given code repositories according to the execution scenario; determining a target repository for executing the to-be-executed operation from the candidate repositories according to the to-be-executed operation; and executing the to-be-executed operation in the target repository according to the operation instruction.
[0005] In a possible implementation manner, the execution scenario includes a default scenario; and the determining the candidate repository for executing the to-be-executed operation from the plurality of given code repositories according to the execution scenario includes: if the execution scenario is the default scenario, determining, according to a current branch of a preset anchor repository, a code repository whose current branch is the same as the current branch of the anchor repository from the plurality of code repositories as the candidate repository.
[0006] In one possible implementation, the execution scenario includes a specified scenario; determining the candidate repository for executing the operation from a given plurality of code repositories based on the execution scenario includes: if the execution scenario is a specified scenario, displaying a repository list and receiving a repository selection instruction; wherein the repository list is used to display information of the plurality of code repositories; and determining the selected code repository from the plurality of code repositories based on the repository selection instruction, and identifying the selected code repository as the candidate repository.
[0007] In one possible implementation, determining the target repository for executing the operation from the candidate repositories based on the operation to be executed includes: determining whether the candidate repository meets the execution conditions of the operation to be executed, and if the candidate repository meets the execution conditions, then determining the candidate repository as the target repository.
[0008] In one possible implementation, the operation to be executed includes a branch merging operation; determining whether the candidate repository meets the execution conditions of the operation to be executed includes: if the operation to be executed is the branch merging operation, then determining the target branch to which the current branch of the candidate repository is merged according to the operation instruction, and determining whether there is a change in the current branch of the candidate repository relative to the corresponding target branch; if there is a change, then determining that the candidate repository meets the execution conditions; if there is no change, then determining that the candidate repository does not meet the execution conditions.
[0009] In one possible implementation, determining whether the current branch of the candidate repository has changed relative to the corresponding target branch includes: obtaining first code version information of the current branch of the candidate repository on the local end and second code version information of the current branch of the candidate repository on the remote end; comparing the first code version information and the second code version information to determine whether the current code version of the current branch of the candidate repository on the local end is the same as the current code version of the current branch of the candidate repository on the remote end; if not, then determining that the current branch of the candidate repository has not changed relative to the corresponding target branch; if yes, then obtaining third code version information of the target branch on the remote end, and based on the third code version information, determining whether the code version updated in each iteration of the target branch includes the current code version of the current branch of the candidate repository; if yes, then determining that the current branch of the candidate repository has not changed relative to the corresponding target branch; if not, then determining that the current branch of the candidate repository has changed relative to the corresponding target branch.
[0010] This application also provides a code repository management device, including: a receiving module for receiving user instructions; a parsing module for determining, based on the user instructions, an operation instruction for indicating an operation to be performed, and an execution scenario for the operation to be performed; a candidate repository determination module for determining, based on the execution scenario, a candidate repository for performing the operation to be performed from a given plurality of code repositories; a target repository determination module for determining, based on the operation to be performed, a target repository for performing the operation to be performed from the candidate repositories; and an operation execution module for performing the operation to be performed in the target repository according to the operation instruction.
[0011] This application also provides an electronic device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; the memory is used to store at least one computer software, and the computer software causes the processor to execute the method described in any of the above embodiments.
[0012] This application also provides a computer storage medium storing a computer program thereon, which, when executed by a processor, implements the method described in any of the foregoing embodiments.
[0013] This application also provides a computer program product, including computer instructions, which instruct a computing device to perform the operations corresponding to the methods described in any of the above embodiments.
[0014] In this embodiment of the application, the operation instruction to indicate the operation to be performed and the execution scenario of the operation to be performed can be determined according to the user instruction; according to the execution scenario, the candidate repository for the operation to be performed can be determined from a plurality of given code repositories; according to the operation to be performed, the target repository for the operation to be performed can be determined from the candidate repositories; and according to the operation instruction, the operation to be performed is executed in the target repository.
[0015] Therefore, when the operation to be performed involves multiple code repositories, the target repository for the operation can be automatically determined from the given multiple code repositories, without requiring the user to switch to each code repository separately, which can significantly save the user's time. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0017] Figure 1This is a schematic diagram of an exemplary system for the code repository management method applicable to embodiments of this application;
[0018] Figure 2 This is a flowchart illustrating the steps of a code repository management method provided in an embodiment of this application;
[0019] Figure 3 This is a flowchart of another code repository management method provided in an embodiment of this application;
[0020] Figure 4 This is a structural block diagram of a code repository management device provided in an embodiment of this application;
[0021] Figure 5 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0022] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of this application.
[0023] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0024] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0025] To improve software development efficiency, modularization has become a trend in software architecture design. Modularization is a design strategy that advocates breaking down large software development projects into smaller, more manageable components or modules. Each module is responsible for a portion of the functionality and interacts with other modules through well-defined interfaces. This approach simplifies the development process, allows software development team members to focus on the tasks of specific modules, and promotes code reuse. Accordingly, each module of the software typically corresponds to a code repository storing that module's code. When the software has multiple modules, multiple code repositories need to be set up to store the code for each module separately.
[0026] However, as mentioned earlier, existing version control tools generally only support operations on a single code repository. When an operation involves multiple code repositories used to store code, existing version control tools can only switch to each code repository one by one to perform the operation, which brings great inconvenience to software development.
[0027] This application provides a code repository management method to at least partially solve the above-mentioned problems.
[0028] Figure 1 An exemplary system for a code repository management method applicable to embodiments of this application is shown. For example... Figure 1 As shown, the system 100 may include a remote terminal 102, a communication network 104, and / or one or more local terminals 106. Figure 1 The example in the text shows multiple local endpoints.
[0029] Remote terminal 102 can be any suitable device for storing information, data, programs, and / or any other suitable type of content, including but not limited to distributed storage system devices, server clusters, computing cloud server clusters, etc. In some embodiments, remote terminal 102 can perform any suitable function. For example, in some embodiments, remote terminal 102 can be used for corresponding operations in code repository management methods. As an optional example, in some embodiments, remote terminal 102 can be used to execute corresponding operations to be performed in the target repository.
[0030] In some embodiments, communication network 104 can be any suitable combination of one or more wired and / or wireless networks. For example, communication network 104 can include any one or more of the following: the Internet, intranet, wide area network (WAN), local area network (LAN), wireless network, digital subscriber line (DSL) network, frame relay network, asynchronous transfer mode (ATM) network, virtual private network (VPN), and / or any other suitable communication network. Local end 106 can be connected to communication network 104 via one or more communication links (e.g., communication link 112), which can be linked to remote end 102 via one or more communication links (e.g., communication link 114). Communication links can be any communication link suitable for transmitting data between local end 106 and remote end 102, such as network links, dial-up links, wireless links, hardwired links, any other suitable communication links, or any suitable combination of such links.
[0031] Local terminal 106 may include any one or more user devices adapted to receive user instructions, determine operation instructions and target warehouses based on user instructions, and enable remote terminal 102 to perform corresponding operations in the target warehouses according to the operation instructions. In some embodiments, local terminal 106 may include any suitable type of device. For example, in some embodiments, local terminal 106 may include mobile devices, tablet computers, laptop computers, desktop computers, wearable computers, and / or any other suitable type of user device.
[0032] Users can develop code locally, upload the completed code to a remote location, and obtain code completed by other users from the remote location, thus enabling collaborative software development through the remote location.
[0033] It should be noted that the code repository used to store code can exist on both the local and remote ends. After completing the code, users can submit the code to a code repository on the local end for storage. Furthermore, the code stored in the local code repository can be uploaded to the same code repository on the remote end for centralized storage, allowing other users to download the code from the remote code repository, thus facilitating collaboration within the user team.
[0034] The local end can include a configuration file that stores code repository configuration information. The code repository configuration information can include the code repository's storage path on the remote end, the code repository's identifier or name on the local end, and the code repository's storage path on the local end.
[0035] The code repository management method provided in this application embodiment will be described in detail below with reference to the accompanying drawings.
[0036] like Figure 2 As shown in the figure, this application provides a code repository management method, including:
[0037] S210: Receive user instructions.
[0038] User commands can be instructions entered by the user.
[0039] As a possible implementation, embodiments of this application may provide an operation unit, which includes an instruction input page for users to input user instructions, thereby enabling the receiving of user instructions through the operation unit.
[0040] As a possible implementation, the configuration file on the local end and the program code for implementing the method of the embodiments of this application can be stored in the folder corresponding to the operation unit.
[0041] S220: Determine the operation instructions to be performed and the execution scenario of the operation based on the user instructions.
[0042] User instructions may include a first part and a second part. The first part may be an operation instruction, and the second part may be a scenario instruction used to indicate the execution scenario. Thus, the operation instruction can be determined based on the first part of the user instructions, and the execution scenario can be determined based on the second part of the user instructions.
[0043] S230: Based on the execution scenario, determine the candidate repositories from a given set of code repositories to execute the operation to be performed.
[0044] The given multiple code repositories can be all code repositories involved in the development of the same software. The candidate repositories can differ depending on the execution scenario. Based on the execution scenario determined in step S220, the candidate repositories for the current scenario are selected from the given multiple code repositories to perform the operation. The given multiple code repositories can be various code repositories involved in the same software, facilitating unified management of all code repositories involved in the software. The number of candidate repositories can be one or more, thus supporting operations on multiple code repositories.
[0045] S240: Based on the operation to be executed, determine the target repository from the candidate repositories to execute the operation.
[0046] It should be noted that for a certain operation to be executed, not all candidate repositories may be able to perform the operation. In this embodiment of the application, the candidate repositories that can perform the operation can be determined from the candidate repositories according to the operation to be executed, and the determined candidate repositories are used as the target repositories for performing the operation.
[0047] In the prior art, a specific operation can only be executed in the current data warehouse. If the same operation needs to be executed in a data warehouse other than the current data warehouse, the user needs to switch to another data warehouse before the operation can be executed. However, in the embodiments of this application, as long as another data warehouse is identified as the target warehouse, the operation can be executed in that data warehouse without the user needing to switch data warehouses, which can improve the efficiency of executing the operation.
[0048] S250: Execute the pending operation in the target warehouse according to the operation instructions.
[0049] Once the target warehouse is identified, the operation to be performed can be executed in each target warehouse according to the operation instructions.
[0050] As a feasible implementation, this application can invoke a given version control tool to execute an operation to be performed in the target repository. Specifically, S150 may include: generating an assembly instruction based on an operation instruction, which is used to invoke the given version control tool to execute the operation to be performed in the target repository. The version control tool is invoked based on this assembly instruction, and the execution result of the operation can then be displayed. The following explanation uses invoking Git software as an example.
[0051] As an example, the user command could be "zit-z push", where "zit" is the name of the program implementing the method in this application, used to call the program. Optionally, the program implementing the method in this application could be a shell script. "push" is the first part of the user command, i.e., the operation command. Specifically, "push" can be used to instruct the code in the local repository to be uploaded to the remote repository. The operation command in this embodiment can be set with reference to version control tools such as Git software; specific details can be found in related technologies, which will not be elaborated here. "-z" is the second part of the user command, i.e., the scenario command. In this embodiment, the execution scenario can include a default scenario and a specified scenario. "-z" can be used to indicate that the execution scenario is a specified scenario. When the user command does not have "-z", it can indicate that the execution scenario is the default scenario.
[0052] Based on the operation command "push", an assembly command can be generated to call the Git software, so that the Git software will perform the "push" operation in each target repository, and the Git software can be called to perform the corresponding operation through the assembly command.
[0053] In this embodiment of the application, the operation instruction to indicate the operation to be performed and the execution scenario of the operation to be performed can be determined according to the user instruction; according to the execution scenario, the candidate repository for the operation to be performed can be determined from a plurality of given code repositories; according to the operation to be performed, the target repository for the operation to be performed can be determined from the candidate repositories; and according to the operation instruction, the operation to be performed is executed in the target repository.
[0054] Therefore, when the operation to be performed involves multiple code repositories, the target repository for the operation can be automatically determined from the given multiple code repositories, without requiring the user to switch to each code repository separately, which can significantly save the user's time.
[0055] In some optional embodiments, the execution scenario includes the default scenario.
[0056] Based on the execution scenario, candidate repositories for executing the operation to be performed are determined from a given set of multiple code repositories, including:
[0057] If the execution scenario is the default scenario, then based on the current branch of the preset anchor repository, the code repositories whose current branches are the same as the current branches of the anchor repository are identified as candidate repositories.
[0058] A branch can be understood as an independent code branch created within a code repository based on a specific commit version. Each branch exists independently, recording its commit history and code status. Common branch types include: master / main branch, develop branch, feature branch, and fix branch. The current branch can be understood as the branch you are currently on. When a software development project includes multiple code repositories, the same branch can exist in multiple repositories. It should be understood that the same branch in different repositories can store different code.
[0059] This application embodiment can pre-set anchor repositories, which can be any one of a given set of code repositories or a separately set repository. The current branch of the anchor repository can change synchronously with the current branch of the code repository currently being used by the user, so that the current branch of the anchor repository can indicate the current branch of the code repository currently being used by the user.
[0060] For example, the code repository being operated on may include a first branch, a second branch, and a third branch. If the current branch of the code repository being operated on is the second branch, then the current branch of the anchor repository is also the second branch. Based on the fact that the current branch of the anchor repository is the second branch, code repositories whose current branch is also the second branch among multiple code repositories can be identified as candidate repositories.
[0061] In this embodiment, the current branch of the anchor repository can indicate the current branch of the code repository currently being used by the user. When the execution scenario is the default scenario, the code repositories whose current branches are the same as the current branches of the anchor repository can be identified as candidate repositories based on the current branches of the preset anchor repository. This allows for the effective filtering of code repositories whose current branches are the same as the code repository currently being used by the user, thereby obtaining code repositories that may perform the above-mentioned operations. This eliminates the need for manual operation by the user, reducing the user's workload and improving the efficiency of code repository management.
[0062] In some alternative embodiments, the execution scenario includes a specified scenario.
[0063] Based on the execution scenario, candidate repositories for executing the operation to be performed are determined from a given set of multiple code repositories, including:
[0064] If the execution scenario is a specified scenario, a list of repositories is displayed, and a repository selection instruction is received; the repository list is used to display information about multiple code repositories; based on the repository selection instruction, the selected code repository among the multiple code repositories is determined, and the selected code repository is identified as a candidate repository.
[0065] The information of a code repository can include the repository's identifier, branch information, etc., as long as it is easy for users to select.
[0066] In this embodiment, the execution scenario also includes a specified scenario. When the execution scenario is a specified scenario, a repository list is displayed and a repository selection instruction is received. Based on the repository selection instruction, the selected code repository among multiple code repositories is determined and designated as a candidate repository. The repository list can display available code repositories for the user to choose from, allowing the user to flexibly select candidate repositories and better meet the user's needs for executing pending operations. Furthermore, in the process of determining candidate repositories in this embodiment, the user only needs to select a code repository from the repository list, without needing to switch between code repositories, which reduces the user's workload and improves the efficiency of code repository management.
[0067] In some optional embodiments, determining the target repository for executing the operation from the candidate repositories based on the operation to be executed includes: determining whether the candidate repository meets the execution conditions of the operation to be executed, and if the candidate repository meets the execution conditions, then determining the candidate repository as the target repository.
[0068] Based on the operation to be executed, the execution conditions required to execute it can be determined. By judging whether a candidate repository meets the execution conditions, it can be determined whether the candidate repository can execute the operation. When a candidate repository meets the execution conditions, it means that the candidate repository can execute the operation, and it can be identified as the target repository. When a candidate repository does not meet the execution conditions, it means that the candidate repository cannot execute the operation, and it can be excluded from the target repository list.
[0069] As a feasible implementation method, a poller can be used to poll each candidate repository in turn to determine whether each candidate repository meets the execution conditions of the operation to be executed.
[0070] In this embodiment of the application, based on the operation to be executed, it is determined whether the candidate warehouse meets the execution conditions of the operation to be executed. The candidate warehouse that does not meet the execution conditions can be excluded from the target warehouse, and only the candidate warehouse that meets the execution conditions can be determined as the target warehouse. Thus, the operation to be executed only needs to be executed in the candidate warehouse that meets the execution conditions, thereby improving the efficiency of executing the operation to be executed and avoiding errors caused by the target warehouse not meeting the execution conditions.
[0071] The following describes the overall process of code repository management. For example... Figure 3 As shown, code repository management methods may include some or all of the following steps:
[0072] S210: Receive user instructions.
[0073] S220: Determine the operation instructions to be performed and the execution scenario of the operation based on the user instructions.
[0074] S221: Determine what kind of scenario the determined execution scenario is.
[0075] S231: If the execution scenario is the default scenario, then based on the current branch of the preset anchor repository, the code repositories whose current branches are the same as the current branches of the anchor repository among multiple code repositories will be determined as candidate repositories.
[0076] S232: If the execution scenario is a specified scenario, then display the list of warehouses and receive warehouse selection instructions.
[0077] S233: Based on the repository selection instruction, determine the selected code repository among multiple code repositories and identify the selected code repository as a candidate repository.
[0078] S241: Based on the operation to be executed, determine whether the candidate repository meets the execution conditions of the operation to be executed.
[0079] S242: If a candidate repository meets the execution conditions, then the candidate repository is determined as the target repository.
[0080] S251: Generate assembly instructions based on operation instructions.
[0081] S252: Based on this assembly instruction, the given version management tool is invoked, causing the version management tool to perform the operation to be performed in the target repository.
[0082] S260: Displays the execution result of the operation to be performed.
[0083] In some optional embodiments, the operation to be performed includes a branch merging operation. Specifically, the branch merging operation can be to merge the current branch of a candidate repository into other branches within that candidate repository, and the merged branch can be denoted as the target branch. The operation instruction can include information indicating the target branch corresponding to the current branch of the candidate repository, thereby determining the target branch corresponding to the current branch of the candidate repository based on the operation instruction.
[0084] Determine whether the candidate repository meets the execution conditions for the operation to be performed, including:
[0085] If the operation to be performed is a branch merge operation, the target branch to which the current branch of the candidate repository is merged is determined according to the operation instruction, and it is determined whether there is a change in the current branch of the candidate repository relative to the corresponding target branch. If there is a change, the candidate repository is determined to meet the execution conditions; if there is no change, the candidate repository is determined not to meet the execution conditions.
[0086] As a feasible implementation, after determining the target branch corresponding to the current branch of the candidate repository, the code version of the current branch of the candidate repository and the code version of the corresponding target branch can be determined. The code version of the current branch of the candidate repository is compared with the code version of the corresponding target branch to determine whether there are any changes in the current branch of the candidate repository relative to the corresponding target branch.
[0087] As a feasible implementation, if the code version of the current branch of the candidate repository is the same as the code version of the corresponding target branch, it can be considered that the current branch of the candidate repository has not changed relative to the corresponding target branch. If the code version of the current branch of the candidate repository is different from the code version of the corresponding target branch, it can be considered that the current branch of the candidate repository has changed relative to the corresponding target branch. Of course, other suitable judgment conditions can also be used to determine whether there is a change in the current branch of the candidate repository relative to the corresponding target branch. The embodiments of this application do not limit the specific judgment conditions.
[0088] In this embodiment, the operation to be performed includes a branch merge operation. When the operation to be performed is a branch merge operation, the target branch to which the current branch of the candidate repository is merged can be determined according to the operation instruction, and it can be determined whether there is a change in the current branch of the candidate repository relative to the corresponding target branch. If there is a change, it is determined that the candidate repository meets the execution conditions; if there is no change, it is determined that the candidate repository does not meet the execution conditions. Thus, candidate repositories whose current branch has no change relative to the corresponding target branch can be excluded from the target repository, and it is not necessary to perform a branch merge operation on the candidate repository. In contrast, in the prior art, a corresponding branch merge operation is created even when the current branch has no change relative to the corresponding target branch. This embodiment can significantly reduce the time for performing branch merge operations compared to the prior art.
[0089] In some optional embodiments, determining whether the current branch of the candidate repository has changed relative to the corresponding target branch includes:
[0090] Get the first code version information of the current branch of the candidate repository on the local end, and the second code version information of the current branch of the candidate repository on the remote end.
[0091] Compare the first code version information and the second code version information to determine whether the current code version of the current branch of the candidate repository on the local end is the same as the current code version of the current branch of the candidate repository on the remote end.
[0092] If not, then it is determined that the current branch of the candidate repository has not changed relative to the corresponding target branch.
[0093] If so, obtain the third code version information of the target branch on the remote end. Based on the third code version information, determine whether the code version of each update of the target branch includes the current code version of the current branch of the candidate repository. If so, determine that the current branch of the candidate repository has not changed relative to the corresponding target branch. If not, determine that the current branch of the candidate repository has changed relative to the corresponding target branch.
[0094] In this embodiment, each code version information may include a corresponding commit ID. A commit ID is a unique identifier used to mark code commits to the data repository, and each commit has its own unique commit ID. It should be understood that committing code is equivalent to updating stored code, thus the commit ID can indicate the code version.
[0095] As a possible implementation, the first code version information of the current branch of the candidate repository on the local machine can include the latest commit ID of the current branch of the candidate repository on the local machine. The second code version information of the current branch of the candidate repository on the remote machine can include the latest commit ID of the current branch of the candidate repository on the remote machine.
[0096] Compare the latest commit ID of the candidate repository's current branch on the local machine with the latest commit ID of the candidate repository's current branch on the remote machine. If the two latest commit IDs are the same, it can be determined that the current code version of the candidate repository's current branch on the local machine is the same as the current code version of the candidate repository's current branch on the remote machine. If the two latest commit IDs are different, it can be determined that the current code version of the candidate repository's current branch on the local machine is different from the current code version of the candidate repository's current branch on the remote machine.
[0097] When the current code version of the current branch of a candidate repository on the local machine is different from its current code version on the remote machine, the local code version of the candidate repository's current branch needs to be synchronized with its remote code version (e.g., the local code version of the candidate repository's current branch needs to be synchronized with its remote code version). A direct branch merge operation cannot be performed. Therefore, when the local code version of the current branch of a candidate repository is different from its remote code version, it can be considered that the current branch of the candidate repository has no change relative to the corresponding target branch. In this embodiment, when the local code version of the current branch of a candidate repository is different from its remote code version, it can be determined that the current branch of the candidate repository has no change relative to the corresponding target branch. That is, the candidate repository is determined to not meet the execution conditions for a branch merge operation, thus avoiding directly performing a branch merge operation on the current branch of the candidate repository and preventing errors in the branch merge operation.
[0098] The third version information of the target branch corresponding to the current branch of the candidate repository on the remote end can include all commit IDs of the target branch on the remote end. This is based on all commit IDs of the target branch on the remote end.
[0099] If the current code version of the current branch of the candidate repository on the local machine is the same as the current code version of the current branch of the candidate repository on the remote machine, then we can determine whether the latest commit ID of the current branch of the candidate repository on both the local machine and the remote machine is included in all commit IDs of the target branch on the remote machine. This will allow us to determine whether the code version of the target branch in each update includes the current code version of the current branch of the candidate repository.
[0100] Specifically, if the target branch's commit IDs on the remote end include the latest commit ID of the candidate repository's current branch on both the local and remote ends, then the code version of each update of the target branch, including the current code version of the candidate repository's current branch, can be determined. If the target branch's commit IDs on the remote end do not include the latest commit ID of the candidate repository's current branch on both the local and remote ends, then the code version of each update of the target branch, excluding the current code version of the candidate repository's current branch, can be determined.
[0101] It should be understood that when the current code version of the current branch of the candidate repository on the local end is the same as the current code version of the current branch of the candidate repository on the remote end, the current code version of the current branch of the candidate repository is equivalent to the current code version of the current branch of the candidate repository on the local end and equivalent to the current code version of the current branch of the candidate repository on the remote end.
[0102] In this embodiment, when the current code version of the current branch of the candidate repository on the local end is the same as the current code version of the current branch of the candidate repository on the remote end, the third code version information of the target branch on the remote end can be obtained. Based on the third code version information, it can be determined whether the code version of the target branch in each update includes the current code version of the current branch of the candidate repository. If the determination result is yes, it can be determined that the current branch of the candidate repository has no change relative to the corresponding target branch. If the determination result is no, it can be determined that the current branch of the candidate repository has changed relative to the corresponding target branch. This eliminates the need for users to manually compare and determine whether the current branch of the candidate repository has changed relative to the corresponding target branch, which improves the efficiency of determining whether the candidate repository meets the execution conditions and avoids errors caused by manual intervention.
[0103] like Figure 4 As shown in the illustration, this application also provides a code repository management device 400, including:
[0104] Receiver module 410 is used to receive user instructions;
[0105] The parsing module 420 is used to determine the operation instructions for indicating the operation to be performed, as well as the execution scenario of the operation to be performed, based on the user instructions.
[0106] The candidate repository determination module 430 is used to determine, based on the execution scenario, a candidate repository from a given set of multiple code repositories for the execution of the operation to be performed.
[0107] The target repository determination module 440 is used to determine the target repository for executing the operation from the candidate repositories based on the operation to be executed;
[0108] The operation execution module 450 is used to execute the operation to be executed in the target warehouse according to the operation instructions.
[0109] It should be noted that the code repository management device provided in this application embodiment is based on the same inventive concept as the aforementioned code repository management method embodiment and can achieve the same effect. For the specific implementation process, please refer to the description in the aforementioned code repository management method embodiment, which will not be repeated here.
[0110] This application also provides an electronic device. Specifically, see the following: [reference needed] Figure 5 This document illustrates a schematic diagram of an electronic device according to an embodiment of this application. The specific embodiments of this application do not limit the specific implementation of the electronic device.
[0111] like Figure 5 As shown, the electronic device may include: a processor 502, a communications interface 504, a memory 506, and a communications bus 508.
[0112] in:
[0113] The processor 502, communication interface 504, and memory 506 communicate with each other via communication bus 508.
[0114] Communication interface 504 is used to communicate with other electronic devices or servers.
[0115] The processor 502 is used to execute at least one computer software 510, specifically the relevant steps in the above-described code repository management method embodiment.
[0116] The processor 502 may be a CPU, an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. The smart device may include one or more processors of the same type, such as one or more CPUs; or it may include processors of different types, such as one or more CPUs and one or more ASICs.
[0117] Memory 506 is used to store at least one piece of computer software 510. Memory 506 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0118] Computer software 510 may include multiple computer instructions. Specifically, computer software 510 can use these multiple computer instructions to cause processor 502 to execute the operations corresponding to the code repository management method described in any of the foregoing method embodiments. The specific implementation of each step in computer software 510 can be found in the corresponding descriptions of the steps and units in the foregoing method embodiments, and has corresponding beneficial effects; therefore, it will not be repeated here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the devices and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and will not be repeated here.
[0119] This application also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the method described in any of the foregoing method embodiments. The storage medium includes, but is not limited to, compact disc read-only memory (CD-ROM), random access memory (RAM), floppy disk, hard disk, or magneto-optical disk.
[0120] This application also provides a computer storage medium storing a computer program thereon, which, when executed by a processor, implements the method described in any of the foregoing method embodiments. The computer storage medium includes, but is not limited to, compact disc read-only memory (CD-ROM), random access memory (RAM), floppy disk, hard disk, or magneto-optical disk.
[0121] This application also provides a computer program product, including computer instructions, which instruct a computing device to perform operations corresponding to the methods described in any of the foregoing method embodiments.
[0122] It should be noted that, depending on the implementation needs, the various components / steps described in the embodiments of this application can be broken down into more components / steps, or two or more components / steps or parts of the operation of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of this application.
[0123] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0124] The above embodiments are only used to illustrate the embodiments of this application, and are not intended to limit the embodiments of this application. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of this application. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of this application, and the patent protection scope of the embodiments of this application should be defined by the claims.
Claims
1. A code repository management method characterized by, The method comprises the following steps: receiving a user instruction; determining an operation instruction for indicating an operation to be performed and an execution scenario of the operation to be performed according to the user instruction; determining a candidate repository for executing the operation to be performed from a plurality of given code repositories according to the execution scenario; determining a target repository for executing the operation to be performed from the candidate repository according to the operation to be performed; executing the operation to be performed in the target repository according to the operation instruction; wherein the execution scenario comprises a default scenario and a specified scenario; and the step of determining the candidate repository for executing the operation to be performed from the plurality of given code repositories according to the execution scenario comprises: if the execution scenario is the default scenario, determining a code repository whose current branch is the same as a current branch of a preset anchor repository from the plurality of code repositories as the candidate repository according to the current branch of the anchor repository; if the execution scenario is the specified scenario, displaying a repository list and receiving a repository selection instruction; wherein the repository list is used to display information of the plurality of code repositories; and determining a selected code repository from the plurality of code repositories according to the repository selection instruction, and determining the selected code repository as the candidate repository.
2. The code repository management method of claim 1, wherein The step of determining the target repository for executing the operation to be performed from the candidate repository according to the operation to be performed comprises: judging whether the candidate repository meets an execution condition of the operation to be performed according to the operation to be performed, and determining the candidate repository as the target repository when the candidate repository meets the execution condition.
3. The code repository management method of claim 2, wherein, The operation to be performed comprises a branch merging operation. The step of judging whether the candidate repository meets the execution condition of the operation to be performed comprises: if the operation to be performed is the branch merging operation, determining a target branch to which a current branch of the candidate repository is merged according to the operation instruction, and judging whether there is a change of the current branch of the candidate repository relative to the corresponding target branch; if there is a change, determining that the candidate repository meets the execution condition; if there is no change, determining that the candidate repository does not meet the execution condition.
4. The code repository management method according to claim 3, wherein the step of judging whether there is a change of the current branch of the candidate repository relative to the corresponding target branch comprises: obtaining first code version information of the current branch of the candidate repository at a local end and second code version information of the current branch of the candidate repository at a remote end; comparing the first code version information and the second code version information to judge whether a current code version of the current branch of the candidate repository at the local end is the same as a current code version of the current branch of the candidate repository at the remote end; if not, determining that there is no change of the current branch of the candidate repository relative to the corresponding target branch; if yes, obtaining third code version information of the target branch at the remote end, and judging whether a code version updated last time of the target branch includes the current code version of the current branch of the candidate repository according to the third code version information. If yes, it is determined that the current branch of the candidate repository has no change relative to the corresponding target branch; if no, it is determined that the current branch of the candidate repository has change relative to the corresponding target branch.
5. A code repository management apparatus characterized by comprising: Comprise: A receiving module configured to receive a user instruction; An analyzing module configured to determine, according to the user instruction, an operation instruction for indicating an operation to be executed, and an execution scenario of the operation to be executed; A candidate repository determining module configured to determine, according to the execution scenario, a candidate repository for executing the operation to be executed from a plurality of given code repositories; A target repository determining module configured to determine, according to the operation to be executed, a target repository for executing the operation to be executed from the candidate repository; An operation executing module configured to execute the operation to be executed in the target repository according to the operation instruction; Wherein, the execution scenario comprises a default scenario and a specified scenario; the candidate repository determining module is configured to: If the execution scenario is the default scenario, determine, according to a current branch of a preset anchor repository, a code repository whose current branch is the same as the current branch of the anchor repository in the plurality of code repositories, as the candidate repository; if the execution scenario is the specified scenario, display a repository list and receive a repository selection instruction; wherein, the repository list is configured to display information of the plurality of code repositories; according to the repository selection instruction, determine a selected code repository in the plurality of code repositories, and determine the selected code repository as the candidate repository.
6. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, the processor, the memory and the communication interface complete communication with each other through the communication bus; The memory is configured to store at least one computer software, and the computer software causes the processor to execute the method in any one of claims 1-4.
7. A computer storage medium having a computer program stored thereon, the program being executed by a processor to implement the method in any one of claims 1-4.
8. A computer program product comprising computer instructions, the computer instructions instructing a computing device to perform operations corresponding to the method in any one of claims 1-4.
Citation Information
Patent Citations
Operation instruction response method and device, equipment and storage medium
CN112631652A
Code warehouse management method and device, electronic equipment and storage medium
CN115904933A