CN106775714B - Code synchronization method and system - Google Patents
Code synchronization method and system Download PDFInfo
- Publication number
- CN106775714B CN106775714B CN201611160667.3A CN201611160667A CN106775714B CN 106775714 B CN106775714 B CN 106775714B CN 201611160667 A CN201611160667 A CN 201611160667A CN 106775714 B CN106775714 B CN 106775714B
- Authority
- CN
- China
- Prior art keywords
- manager
- identifier
- intermediate server
- project
- code
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 52
- 230000001360 synchronised effect Effects 0.000 claims abstract description 76
- 238000004891 communication Methods 0.000 claims description 10
- 230000006870 function Effects 0.000 description 9
- 238000011161 development Methods 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The invention provides a code synchronization method and a system, wherein the method comprises the following steps: receiving a synchronization notice sent by a first manager, wherein the synchronization notice carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log; acquiring a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from a first manager according to the identifier of the first manager; and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager. The invention adds the intermediate server between the first manager and the second manager, realizes the code synchronization between the first manager and the second manager through the intermediate server, can realize the code synchronization between Git and SVN, and ensures that developers in companies adopting SVN can use Git as a code management tool.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a code synchronization method and system.
Background
Currently, SVN (version control system for open source code) and Git (distributed version control system) are two version control tools commonly used for code development.
Git is a version control tool for Linux kernel development, adopts a distributed version library mode, does not need server-side software support, and makes source code release and communication extremely convenient. The SVN adopts a branch management system for multiple persons to jointly develop the same project and realize the shared resource of the multiple persons developing the same project. The flexibility and versatility of Git is incomparable by SVN for developers familiar with code development. Many developers are used to code management by using Git, but many companies use SVN as a code management tool, and because Git and SVN cannot realize synchronous code management currently, developers of companies using SVN cannot manage codes by using Git.
Therefore, a code synchronization scheme is urgently needed to achieve code synchronization between Git and SVN so that developers in companies that manage codes using SVN can use Git as a code management tool.
Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a code synchronization method and system, in which an intermediate server is added between a first manager and a second manager, the code synchronization between the first manager and the second manager is realized through the intermediate server, the code synchronization between Git and SVN can be realized, and developers in companies using SVN can use Git as a code management tool.
In a first aspect, an embodiment of the present invention provides a code synchronization method, where the method includes:
receiving a synchronization notification sent by a first manager, wherein the synchronization notification carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log;
acquiring a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier;
acquiring a code to be synchronized from the first manager according to the identifier of the first manager;
and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager.
With reference to the first aspect, an embodiment of the present invention provides a first possible implementation manner of the first aspect, where the obtaining, according to the identifier of the second manager and the item identifier, an item file corresponding to the item identifier includes:
judging whether a project file corresponding to the project identifier exists in a local memory or not according to the project identifier;
if yes, directly acquiring a project file corresponding to the project identifier from a local memory;
if not, sending an acquisition request to the second manager according to the identifier of the second manager, wherein the acquisition request carries the item identifier, and receiving the item file corresponding to the item identifier sent by the second manager.
With reference to the first aspect, an embodiment of the present invention provides a second possible implementation manner of the first aspect, where before receiving the synchronization notification sent by the first manager, the method further includes:
generating a digital certificate for communication with a first manager and a second manager;
and executing the permission giving instruction to obtain the read-write permission of the local file.
With reference to the first aspect, an embodiment of the present invention provides a third possible implementation manner of the first aspect, where the method further includes:
and acquiring the item identifier and the item file of each item from the second manager every other preset time period, and storing the corresponding relation between the item identifier and the item file of each item.
With reference to the first aspect or any one of the first to third possible implementation manners of the first aspect, an embodiment of the present invention provides a fourth possible implementation manner of the first aspect, where,
the first manager is a distributed version control system Git manager, and the second manager is an open source code version control system SVN manager; or,
the first manager is an SVN manager, and the second manager is a Git manager.
In a second aspect, an embodiment of the present invention provides a code synchronization method, where the method includes:
sending a synchronous notification to an intermediate server, wherein the synchronous notification carries the identifier of the first manager, the identifier of the second manager, the item identifier and a submission log;
and when an acquisition request of the intermediate server for acquiring the code is received, transmitting the code to be synchronized to the intermediate server so that the intermediate server synchronizes the code to be synchronized to the second manager.
With reference to the second aspect, an embodiment of the present invention provides a first possible implementation manner of the second aspect, where the method further includes:
when an acquisition request carrying a project identifier sent by the intermediate server is received, sending a project file corresponding to the project identifier to the intermediate server;
and receiving the synchronous file sent by the intermediate server.
With reference to the second aspect or the first possible implementation manner of the second aspect, an embodiment of the present invention provides a second possible implementation manner of the second aspect, where,
the first manager is a Git manager, and the second manager is an SVN manager; or,
the first manager is an SVN manager, and the second manager is a Git manager.
In a third aspect, an embodiment of the present invention provides a code synchronization system, where the system includes a first manager, an intermediate server, and a second manager;
the first manager is used for sending a synchronization notice to the intermediate server, transmitting a code to be synchronized to the intermediate server when receiving an acquisition request of the intermediate server for acquiring the code, wherein the synchronization notice carries an identifier of the first manager, an identifier of the second manager, an item identifier and a submission log;
the intermediate server is used for receiving the synchronous notification and acquiring the project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from the first manager according to the identifier of the first manager; adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager;
the second manager is used for sending the project file corresponding to the project identifier to the intermediate server when receiving an acquisition request which is sent by the intermediate server and carries the project identifier; and receiving the synchronous file sent by the intermediate server.
With reference to the third aspect, an embodiment of the present invention provides a first possible implementation manner of the third aspect, where,
the first manager is a Git manager, and the second manager is an SVN manager; or,
the first manager is an SVN manager, and the second manager is a Git manager.
In the method and the system provided by the embodiment of the invention, a synchronization notice sent by a first manager is received, wherein the synchronization notice carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log; acquiring a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from a first manager according to the identifier of the first manager; and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager. The invention adds the intermediate server between the first manager and the second manager, realizes the code synchronization between the first manager and the second manager through the intermediate server, can realize the code synchronization between Git and SVN, and ensures that developers in companies adopting SVN can use Git as a code management tool.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a flowchart illustrating a code synchronization method provided in embodiment 1 of the present invention;
FIG. 2 is a system architecture diagram illustrating code synchronization between a Git and an SVN according to embodiment 1 of the present invention;
fig. 3 is a flowchart illustrating a code synchronization method according to embodiment 2 of the present invention;
fig. 4 is a flowchart illustrating a code synchronization method provided in embodiment 3 of the present invention;
fig. 5 is a schematic structural diagram illustrating a code synchronization system provided in embodiment 4 of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Considering that Git and SVN cannot implement synchronous code management in the related art, developers of companies using SVN cannot manage codes using Git. Based on this, embodiments of the present invention provide a method and a system for code synchronization, which are described below by way of embodiments.
Example 1
The embodiment of the invention provides a code synchronization method.
The method is based on a system comprising a first manager, an intermediate server and a second manager, and the code synchronization between the first manager and the second manager can be realized just by adding the intermediate server between the first manager and the second manager. Before performing the code synchronization operation, the intermediate server needs to generate a digital certificate for communicating with the first manager and the second manager. After the intermediate server generates the digital certificate, the digital certificate is configured on the first manager and the second manager. And then, the intermediate server carries the digital certificate when communicating with the first manager and the second manager every time, and certificate communication is carried out between the digital certificate and the first manager and between the digital certificate and the second manager, so that the safety of the first manager and the second manager is ensured, and the normal communication between the intermediate server and the first manager and between the intermediate server and the second manager can be ensured.
In the code synchronization process, the intermediate server needs to read and write the local file, so that before the code synchronization is performed through the system, the intermediate server also executes the authority giving instruction to obtain the read and write authority of the local file.
The first manager and the second manager are both provided with a hook function, and the first manager and the second manager establish communication connection with the intermediate server through the hook function. The first manager and the second manager are both provided with a hook establisher, and before code synchronization by the system, a hook is established in the first manager by the hook establisher on the first manager, and a hook is established in the second manager by the hook establisher on the second manager.
The intermediate server generates a digital certificate, configures the digital certificate on the first manager and the second manager, gives the intermediate server read-write authority to the local file, and establishes a hook on the first manager and the second manager respectively, and then establishes a code synchronization system consisting of the first manager, the intermediate server and the second manager. Based on the established code synchronization system, the method provided by the embodiment of the invention can realize the code synchronization between the first manager and the second manager.
The intermediate server may be a PHP (Hypertext Preprocessor) server. The first manager is a Git manager and the second manager is an SVN manager. Or the first manager is an SVN manager and the second manager is a Git manager. The embodiment of the invention can realize the code synchronization between the Git and the SVN, so that developers can select the code management tool used by themselves without considering the code management tool used by companies.
Referring to fig. 1, the method specifically includes the following steps:
step 101: the first manager sends a synchronization notice to the intermediate server, wherein the synchronization notice carries the identifier of the first manager, the identifier of the second manager, the item identifier and the submission log.
In the embodiment of the invention, the first manager is a code management tool used by a developer, and for a development project, when the developer writes new codes, the new codes are codes to be synchronized. When writing the code to be synchronized, the developer also writes a submission log corresponding to the code to be synchronized, and the submission log may include information such as the writing purpose corresponding to the code to be synchronized.
After the developers write the codes to be synchronized and the corresponding submission logs, the codes to be synchronized and the submission logs are uploaded to the first manager. The developer can upload the code to be synchronized and the submission log through a code submission interface provided by the first manager, and can also upload the code to be synchronized and the submission log to the first manager by writing a submission command.
When a developer writes a code to be synchronized and a submitted log, and uploads the code to be synchronized and the submitted log to a first manager, the first manager sends a synchronization notice to an intermediate server through a hook of the first manager, wherein the synchronization notice carries an identifier of the first manager, an identifier of a second manager, a project identifier and the submitted log. The identifier of the first manager may be an address or an equipment serial number of the first manager, the identifier of the second manager may be an address or an equipment serial number of the second manager, and the identifier of the item may be an item name of an item to which the code to be synchronized belongs.
In the embodiment of the present invention, the synchronization notification is a json (javaScript object notation) string.
After the first manager sends the synchronization notification to the intermediate server, the intermediate server first obtains the item file of the item to which the code to be synchronized belongs according to the identifier and the item identifier of the second manager through the following operation of step 102 and step 106, that is, obtains the item file corresponding to the item identifier carried by the synchronization notification.
Step 102: the intermediate server receives the synchronization notification sent by the first manager, and judges whether an item file corresponding to the item identifier exists in the local memory according to the item identifier carried by the synchronization notification, if so, step 103 is executed, and if not, step 104 is executed.
In the embodiment of the invention, the intermediate server executes the monitoring program to monitor whether the information sent by the first manager or the second manager is received in real time. When the first manager sends a synchronization notification to the intermediate server, a listener of the intermediate server hears the synchronization notification, the synchronization notification being a json string that includes an identification of the first manager, an identification of the second manager, an item identification, and a commit log. The intermediate server calls a decode function json _ decode () to convert the json string to a json object. And subsequently carrying out code synchronization operation by calling the json object.
And after the intermediate server obtains the synchronous notification, checking whether the project file corresponding to the project identifier exists in the corresponding relation between the project identifier stored in the local memory and the project file or not according to the project identifier carried by the synchronous notification.
Step 103: the intermediate server directly obtains the project file corresponding to the project identifier from the local memory, and then executes step 107.
And 104, the intermediate server sends an acquisition request to the second manager according to the identifier of the second manager carried by the synchronous notification, wherein the acquisition request carries the item identifier.
When the project file corresponding to the project identifier does not exist in the local memory of the intermediate server, the intermediate server needs to acquire the project file corresponding to the project identifier from the second manager.
Step 105: and the second manager receives the acquisition request sent by the intermediate server and sends the project file corresponding to the project identifier to the intermediate server.
And the second manager receives the acquisition request, acquires a corresponding project file from the corresponding relation between the project identifier and the project file according to the project identifier carried by the acquisition request, and returns the acquired project file to the intermediate server.
Step 106: and the intermediate server receives the project file corresponding to the project identification sent by the second manager.
In the embodiment of the present invention, assuming that the second manager is an SVN manager, the intermediate server obtains the project file by executing a function exec ("SVN checkout path"). Wherein, path is the identifier of the second manager carried by the synchronization notification.
After the operation of the above step 102 and step 106 ensure that the item file corresponding to the item identifier exists in the local memory of the intermediate server, the intermediate server obtains the code to be synchronized from the first manager through the following step 107 and step 109.
Step 107: and the intermediate server sends an acquisition request for acquiring the code to the first manager according to the identifier of the first manager.
Step 108: the first manager receives the acquisition request and transmits the code to be synchronized to the intermediate server.
In the embodiment of the present invention, assuming that the first manager is a Git manager, after acquiring the project file, the intermediate server executes a function exec ("Git clone …") to acquire the code to be synchronized.
Step 109: and the intermediate server receives the codes to be synchronized transmitted by the first manager, and adds the codes to be synchronized in the project file to obtain a synchronization file.
In the embodiment of the invention, after acquiring the code to be synchronized from the first manager, the intermediate server adds the code to be synchronized in the project file, so that the code of the developer on the first manager is combined with the project code on the second manager to obtain the synchronized file.
Assuming that the first manager is a Git manager, executing the function exec ("Git pull") adds the code to be synchronized to the project file.
Step 110: the intermediate manager sends the commit log and the synchronization file to the second manager.
And the intermediate manager sends the submission log carried by the synchronization notification and the synchronization file to the second manager according to the identifier of the second manager.
Assuming that the second manager is an SVN manager, the intermediate server executes a function exec ("SVN commit ×) to commit the synchronization file to the SVN library, and then executes a function exec (" SVN commit-m "commit log") to commit the commit log carried by the synchronization notification to the SVN library.
Step 111: the second manager receives the synchronization file sent by the intermediate server.
The method realizes the synchronization of the code to be synchronized on the first manager to the second manager. In the embodiment of the present invention, the code to be synchronized in the second manager may also be synchronized to the first manager, at this time, it is equivalent to the identity exchange between the first manager and the second manager, the original second manager executes the operation of the first manager, and the original first manager executes the operation of the second manager.
In the embodiment of the present invention, in order to avoid the operation of step 104 and step 106 and increase the speed of code synchronization, the intermediate server may further obtain the item identifier and the item file of each item from the second manager every preset time period, and store the corresponding relationship between the item identifier and the item file of each item. Therefore, the project files of the projects to which the codes to be synchronized belong are stored in the local memory of the intermediate server, the project files are prevented from being temporarily acquired from the second manager during code synchronization, and the code synchronization efficiency is improved.
As shown in fig. 2, the embodiment of the present invention may implement code synchronization between a Git manager and an SVN manager, add a PHP server between the Git manager and the SVN manager to perform monitoring, and a developer submits a code to be synchronized to Git, and the SVN manager performs public management.
In the embodiment of the invention, a synchronization notice sent by a first manager is received, wherein the synchronization notice carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log; acquiring a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from a first manager according to the identifier of the first manager; and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager. The invention adds the intermediate server between the first manager and the second manager, realizes the code synchronization between the first manager and the second manager through the intermediate server, can realize the code synchronization between Git and SVN, and ensures that developers in companies adopting SVN can use Git as a code management tool.
Example 2
Referring to fig. 3, an embodiment of the present invention provides a code synchronization method, where an execution subject of the method is an intermediate server in the code synchronization method provided in embodiment 1, and the method specifically includes the following steps:
step 201: and receiving a synchronization notice sent by the first manager, wherein the synchronization notice carries the identifier of the first manager, the identifier of the second manager, the item identifier and the submission log.
Step 202: and acquiring the project file corresponding to the project identifier according to the identifier of the second manager and the project identifier.
Step 203: and acquiring the code to be synchronized from the first manager according to the identification of the first manager.
Step 204: and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager.
The obtaining of the project file corresponding to the project identifier according to the identifier of the second manager and the project identifier includes:
judging whether a project file corresponding to the project identifier exists in the local memory or not according to the project identifier;
if yes, directly acquiring the project file from the local memory;
if not, sending an acquisition request to the second manager according to the identifier of the second manager, wherein the acquisition request carries the item identifier, and receiving the item file corresponding to the item identifier sent by the second manager.
In this embodiment of the present invention, before receiving the synchronization notification sent by the first manager, the method further includes:
generating a digital certificate for communicating with the first manager and the second manager;
and executing the permission giving instruction to obtain the read-write permission of the local file.
In order to avoid temporarily acquiring the project file from the second manager, in the embodiment of the present invention, the project identifier and the project file of each project are further acquired from the second manager every preset time period, and the corresponding relationship between the project identifier and the project file of each project is stored.
In the embodiment of the invention, the first manager is a Git manager, and the second manager is an SVN manager; or the first manager is an SVN manager and the second manager is a Git manager.
In the embodiment of the invention, a synchronization notice sent by a first manager is received, wherein the synchronization notice carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log; acquiring a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from a first manager according to the identifier of the first manager; and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager. The invention adds the intermediate server between the first manager and the second manager, realizes the code synchronization between the first manager and the second manager through the intermediate server, can realize the code synchronization between Git and SVN, and ensures that developers in companies adopting SVN can use Git as a code management tool.
Example 3
Referring to fig. 4, an embodiment of the present invention provides a code synchronization method, where an execution subject of the method is a first manager in the code synchronization method provided in embodiment 1, and the method specifically includes the following steps:
step 301: and sending a synchronization notice to the intermediate server, wherein the synchronization notice carries the identifier of the first manager, the identifier of the second manager, the item identifier and the submission log.
Step 302: and when an acquisition request of the intermediate server for acquiring the code is received, transmitting the code to be synchronized to the intermediate server so that the intermediate server synchronizes the code to be synchronized to the second manager.
The code to be synchronized in the first manager is synchronized to the second manager in the above manner. In the embodiment of the present invention, the code to be synchronized in the second manager may also be synchronized to the first manager, where the second manager executes the operations in steps 301 and 302, and the first manager sends the item file corresponding to the item identifier to the intermediate server when receiving the acquisition request carrying the item identifier sent by the intermediate server; and receiving the synchronous file sent by the intermediate server.
In the embodiment of the invention, the first manager is a Git manager, and the second manager is an SVN manager; or the first manager is an SVN manager and the second manager is a Git manager.
In the embodiment of the invention, a synchronization notice sent by a first manager is received, wherein the synchronization notice carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log; acquiring a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from a first manager according to the identifier of the first manager; and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager. The invention adds the intermediate server between the first manager and the second manager, realizes the code synchronization between the first manager and the second manager through the intermediate server, can realize the code synchronization between Git and SVN, and ensures that developers in companies adopting SVN can use Git as a code management tool.
Example 4
Referring to fig. 5, an embodiment of the present invention provides a code synchronization system, which is configured to execute the code synchronization method provided in embodiment 1. The system includes a first manager 401, an intermediate server 402, and a second manager 403;
the first manager 401 is configured to send a synchronization notification to the intermediate server 402, transmit a to-be-synchronized code to the intermediate server 402 when receiving an acquisition request of the intermediate server 402 for acquiring the code, where the synchronization notification carries an identifier of the first manager 401, an identifier of the second manager 403, an item identifier, and a commit log;
the intermediate server 402 is configured to receive the synchronization notification, and obtain a project file corresponding to the project identifier according to the identifier of the second manager 403 and the project identifier; acquiring a code to be synchronized from the first manager 401 according to the identifier of the first manager 401; adding a code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager 403;
the second manager 403 is configured to send, when receiving an acquisition request carrying an item identifier sent by the intermediate server 402, an item file corresponding to the item identifier to the intermediate server 402; the synchronization file sent by the intermediate server 402 is received.
The first manager 401 is a Git manager, and the second manager 403 is an SVN manager; alternatively, the first manager 401 is an SVN manager and the second manager 403 is a Git manager.
In this embodiment of the present invention, specific operation details of the first manager 401, the intermediate server 402, and the second manager 403 are the same as the operations of the first manager, the intermediate server, and the second manager mentioned in embodiment 1, respectively, and are not described herein again.
In the embodiment of the invention, a synchronization notice sent by a first manager is received, wherein the synchronization notice carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log; acquiring a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from a first manager according to the identifier of the first manager; and adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager. The invention adds the intermediate server between the first manager and the second manager, realizes the code synchronization between the first manager and the second manager through the intermediate server, can realize the code synchronization between Git and SVN, and ensures that developers in companies adopting SVN can use Git as a code management tool.
The system provided by the embodiment of the present invention has the same implementation principle and technical effect as the foregoing method embodiment, and for the sake of brief description, no mention is made in the system embodiment, and reference may be made to the corresponding contents in the foregoing method embodiment. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system described above may all refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided by the present invention, it should be understood that the disclosed system and method can be implemented in other ways. The above-described system embodiments are merely illustrative, and for example, the division of the units is only one logical functional division, and there may be other divisions in actual implementation, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments provided by the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus once an item is defined in one figure, it need not be further defined and explained in subsequent figures, and moreover, the terms "first", "second", "third", etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the present invention in its spirit and scope. Are intended to be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.
Claims (10)
1. A code synchronization method, characterized in that it is based on a system comprising a first manager, an intermediate server and a second manager; the method comprises the following steps:
the intermediate server receives a synchronization notification sent by a first manager, wherein the synchronization notification carries an identifier of the first manager, an identifier of a second manager, an item identifier and a submission log;
the intermediate server acquires a project file corresponding to the project identifier according to the identifier of the second manager and the project identifier;
the intermediate server acquires a code to be synchronized from the first manager according to the identifier of the first manager;
and the intermediate server adds the code to be synchronized in the project file to obtain a synchronization file, and sends the submission log and the synchronization file to the second manager.
2. The method according to claim 1, wherein the obtaining of the project file corresponding to the project identifier according to the identifier of the second manager and the project identifier comprises:
judging whether a project file corresponding to the project identifier exists in a local memory or not according to the project identifier;
if yes, directly acquiring a project file corresponding to the project identifier from a local memory;
if not, sending an acquisition request to the second manager according to the identifier of the second manager, wherein the acquisition request carries the item identifier, and receiving the item file corresponding to the item identifier sent by the second manager.
3. The method of claim 1, wherein before receiving the synchronization notification sent by the first manager, the method further comprises:
generating a digital certificate for communication with a first manager and a second manager;
and executing the permission giving instruction to obtain the read-write permission of the local file.
4. The method of claim 1, further comprising:
and acquiring the item identifier and the item file of each item from the second manager every other preset time period, and storing the corresponding relation between the item identifier and the item file of each item.
5. The method according to any one of claims 1 to 4,
the first manager is a distributed version control system Git manager, and the second manager is an open source code version control system SVN manager; or,
the first manager is an SVN manager, and the second manager is a Git manager.
6. A code synchronization method, characterized in that it is based on a system comprising a first manager, an intermediate server and a second manager; the method comprises the following steps:
the first manager sends a synchronization notice to an intermediate server, wherein the synchronization notice carries the identifier of the first manager, the identifier of the second manager, the item identifier and a submission log;
when receiving an acquisition request of the intermediate server for acquiring the code, the first manager transmits the code to be synchronized to the intermediate server, so that the intermediate server synchronizes the code to be synchronized to the second manager.
7. The method of claim 6, further comprising:
when an acquisition request carrying a project identifier sent by the intermediate server is received, sending a project file corresponding to the project identifier to the intermediate server;
and receiving the synchronous file sent by the intermediate server.
8. The method according to claim 6 or 7,
the first manager is a Git manager, and the second manager is an SVN manager; or,
the first manager is an SVN manager, and the second manager is a Git manager.
9. A code synchronization system, comprising a first manager, an intermediate server, and a second manager;
the first manager is used for sending a synchronization notice to the intermediate server, transmitting a code to be synchronized to the intermediate server when receiving an acquisition request of the intermediate server for acquiring the code, wherein the synchronization notice carries an identifier of the first manager, an identifier of the second manager, an item identifier and a submission log;
the intermediate server is used for receiving the synchronous notification and acquiring the project file corresponding to the project identifier according to the identifier of the second manager and the project identifier; acquiring a code to be synchronized from the first manager according to the identifier of the first manager; adding the code to be synchronized into the project file to obtain a synchronization file, and sending the submission log and the synchronization file to the second manager;
the second manager is used for sending the project file corresponding to the project identifier to the intermediate server when receiving an acquisition request which is sent by the intermediate server and carries the project identifier; and receiving the synchronous file sent by the intermediate server.
10. The system of claim 9,
the first manager is a Git manager, and the second manager is an SVN manager; or,
the first manager is an SVN manager, and the second manager is a Git manager.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611160667.3A CN106775714B (en) | 2016-12-15 | 2016-12-15 | Code synchronization method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611160667.3A CN106775714B (en) | 2016-12-15 | 2016-12-15 | Code synchronization method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106775714A CN106775714A (en) | 2017-05-31 |
CN106775714B true CN106775714B (en) | 2020-10-16 |
Family
ID=58887683
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611160667.3A Active CN106775714B (en) | 2016-12-15 | 2016-12-15 | Code synchronization method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106775714B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108038028B (en) * | 2017-12-13 | 2021-03-23 | 北信源系统集成有限公司 | File backup method and device and file restoration method and device |
CN108196877B (en) * | 2018-01-16 | 2019-01-29 | 北京三快在线科技有限公司 | The method and apparatus and calculating equipment of component release management |
CN109725927B (en) * | 2018-05-08 | 2023-07-21 | 中国平安人寿保险股份有限公司 | Synchronization method and device of code management system, storage medium and terminal |
CN111124467B (en) * | 2018-10-31 | 2023-09-01 | 上海哔哩哔哩科技有限公司 | Authority role display method, system, computer equipment and readable storage medium |
CN109787997B (en) * | 2019-02-26 | 2021-06-11 | 上海易点时空网络有限公司 | PHP-based TCP (Transmission control protocol) service method and server |
CN111338687A (en) * | 2020-02-26 | 2020-06-26 | 北京慧博科技有限公司 | Method for migrating svn version libraries to git version libraries using python |
CN111459538B (en) * | 2020-04-07 | 2024-02-13 | 中国建设银行股份有限公司 | Code synchronization method and device |
CN114221971B (en) * | 2021-12-15 | 2024-04-19 | 中国建设银行股份有限公司 | Data synchronization method, device, server, storage medium and product |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103581247A (en) * | 2012-07-30 | 2014-02-12 | 杭州洱海科技有限公司 | Method for testing distributed type Web based on cloud computing environment |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8719179B2 (en) * | 2012-04-30 | 2014-05-06 | Gild, Inc. | Recruiting service graphical user interface |
-
2016
- 2016-12-15 CN CN201611160667.3A patent/CN106775714B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103581247A (en) * | 2012-07-30 | 2014-02-12 | 杭州洱海科技有限公司 | Method for testing distributed type Web based on cloud computing environment |
Non-Patent Citations (3)
Title |
---|
git-svn-让git和svn协同工作;小稀稀和她的小摩的;《https://www.cnblogs.com/djoel/p/5757674.html》;20161114;第1页 * |
There is any way to synchronize GIT and Subversion repositories?;bla;《https://stackoverflow.com/questions/907913/there-is-any-way-to-synchronize-git-and-subversion-repositories》;20110703;第1-2页 * |
window下svn,git混合使用;weixin_34109408;《https://blog.csdn.net/weixin_34109408/article/details/91638052》;20151104;第1页 * |
Also Published As
Publication number | Publication date |
---|---|
CN106775714A (en) | 2017-05-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106775714B (en) | Code synchronization method and system | |
CN106843978B (en) | SDK access method and system | |
CN106445548B (en) | Test packet issuing method and device | |
CN110007936B (en) | Data processing method and device | |
WO2019062634A1 (en) | Communication method and apparatus | |
US20200026893A1 (en) | Managing a plurality of tag reader devices | |
CN113220479B (en) | Workflow scheduling method and device based on isolation network and electronic equipment | |
US10216553B2 (en) | Message oriented middleware with integrated rules engine | |
CN108366098B (en) | Data interaction method and device for network nodes | |
CN113778442A (en) | System menu generating method, device, equipment and storage medium | |
CN111228819B (en) | Method, device and equipment for protecting Shader | |
CN114896078A (en) | Data synchronization method, system, device and equipment | |
CN108132832B (en) | Application program starting method and device | |
CN110908708A (en) | Code publishing method, device and system | |
CN111177536A (en) | Method and device for transmitting customized information to unregistered user based on device fingerprint and electronic device | |
EP3563321A1 (en) | Detection and delegation of action tasks | |
CN109218338B (en) | Information processing system, method and device | |
EP3276914A1 (en) | Data sharing method and device for virtual desktop | |
CN112738249A (en) | File uploading method, device, equipment and storage medium based on quantitative transaction | |
CN112825525A (en) | Method and apparatus for processing transactions | |
US10728323B2 (en) | Method and apparatus for operating infrastructure layer in cloud computing architecture | |
CN110545296A (en) | Log data acquisition method, device and equipment | |
CN110505277B (en) | Data caching method and device and client | |
CN103970860B (en) | Method, device and system for processing data | |
CN111324368B (en) | Data sharing method and server |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |