Intelligent synchronization method and device, computer equipment and storage medium

By acquiring users' synchronization request messages and using difference analysis algorithms and Git version history for intelligent synchronization, the problems of low synchronization efficiency and poor accuracy in existing technologies are solved, achieving automated and accurate file synchronization.

CN121579601APending Publication Date: 2026-02-27SHENZHEN YOUYOU INTERNET TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610093629.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-23
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing technologies cannot quickly and efficiently synchronize different versions of files, especially similar code or text content. They are difficult to preserve differences, inefficient, and prone to errors.

Method used

By obtaining the user's synchronization request message, the information of the source and target files is determined, the file change patch is calculated using the difference analysis algorithm, and intelligent synchronization is performed based on the Git version history to achieve incremental merging and difference retention.

Benefits of technology

It achieves highly automated code synchronization, significantly reducing the cost of manual intervention, improving synchronization efficiency and accuracy, reducing the occurrence of conflicts, and providing detailed operation logs and real-time feedback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579601A_ABST
    Figure CN121579601A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of software development, and discloses an intelligent synchronization method and device, computer equipment and a storage medium, and the method comprises the steps: obtaining a synchronization request message sent by a user on a user operation interface; the synchronization request message comprises information of a source file needing to be synchronized; the information of the source file needing to be synchronized comprises the current submitted content of the source file; according to the synchronization request information, determining a source file and target files of various versions corresponding to the source file; comparing the difference between the currently submitted content of the source file and the content submitted in the parent to obtain difference data; determining corresponding context lines in the source file and the target file of each version according to the current submitted content and the difference data; and performing synchronization operation on the context line to obtain a synchronized source file and the synchronized target file of each version. According to the embodiment of the invention, the synchronization of the files of different versions is realized on the basis of keeping the differentiation of the files of different versions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of software development technology, specifically to an intelligent synchronization method, apparatus, computer device, and computer-readable storage medium. Background Technology

[0002] Currently, there is a lack of tools on the market capable of intelligently synchronizing similar code or text content. In existing scenarios, such as different versions of an app, although the functional modules are highly similar in structure and logic, each app has specific differentiated requirements (such as page layout, specific function implementation, etc.). In this situation: 1. High difficulty in synchronization: When a module undergoes significant changes, existing technologies cannot quickly and efficiently synchronize the changes to other similar modules or products, and manual operation is prone to missing key differences.

[0003] 2. Complexity in retaining differences: Users need to retain the differences between various products or documents at the same time, such as different versions of Word documents, novel texts or similar code modules. Existing technology has difficulty in intelligently distinguishing between differences and similar parts during the synchronization process.

[0004] 3. Low efficiency: Manual comparison and merging is time-consuming, labor-intensive, and prone to errors, affecting the overall development and creation efficiency. Summary of the Invention

[0005] In view of the above problems, embodiments of the present invention provide an intelligent synchronization method, apparatus, computer device, and computer-readable storage medium to solve the problem in the prior art that it is impossible to quickly and efficiently synchronize different versions of files.

[0006] According to one aspect of the present invention, an intelligent synchronization method is provided, the method comprising: Obtain a synchronization request message sent by the user in the user operation interface; the synchronization request message includes information about the source file to be synchronized; the information about the source file to be synchronized includes the current commit content of the source file, source repository information and target repository information; Based on the synchronization request information, the source file information and the target file information for each version of the source file are determined; the source file information includes the source file path and the current submission status; Compare the current commit content of the source file with the content of the parent commit to obtain the difference data; Based on the current commit content, the current commit content status, and the difference data, determine the corresponding context lines in the target files of each version; Based on the current submission status, the context line is synchronized to obtain the synchronized source file and the synchronized target files for each version.

[0007] In one alternative approach, prior to obtaining the synchronization request message sent by the user on the user interface, the method includes: Retrieve multiple Git repositories added by the user through the user interface and generate a list of Git repositories; the information of the Git repository includes the Git repository name, repository ID and local repository path; The step of obtaining the synchronization request message sent by the user in the user operation interface includes: Get the current submission content of the user to the source file in the user operation interface; Based on the current commit content of the source file, obtain the target repository list corresponding to the source repository, and return the target repository list to the user; Retrieve the repository information of the target repository selected by the user in the target repository list that needs to be synchronized; A synchronization request message is generated based on the current commit content of the source file, the source repository information, and the repository information selected from the repository list to be synchronized.

[0008] In one optional approach, the source repository information includes the source repository name, source repository ID, and source repository local repository path; the target repository information includes the target repository name, target repository ID, and target repository local repository path. The step of determining the source file information and the target file information for each version of the source file based on the synchronization request information further includes: Based on the current commit content of the source file and the source repository information, query the source file path of the source file in the source repository; Based on the current submission content, the status of the current submission content is determined by matching the status code using a preset regular expression; the status code indicates that the current submission content status is any one of addition, deletion, modification, or renaming. Output the source repository information, including the current submission status and the source file path. Based on the current submission content and target repository information, retrieve the target file information from the target repository.

[0009] In one alternative approach, the differences between the current commit content of the source file and the content of the parent commit are compared to obtain difference data, including: Retrieve the current commit content and the corresponding parent commit content of the source file; The source file path, the content of the parent commit, and the content of the current commit are input into the patch generation method of the Diff library to determine the difference data. The difference data includes the change operation information of the current commit to the source file, and the change operation information includes the change location and change content on a line-by-line basis. The change operation includes adding, deleting, and modifying.

[0010] In one optional approach, determining the corresponding context line in the target file for each version based on the current commit content, the current commit content status, and the difference data includes: By using a context matching mechanism through a patch application algorithm, the context line corresponding to the current commit content in the target file of each version is determined based on the current commit content, the current commit content status, and the difference data.

[0011] In one optional approach, the step of synchronizing the context lines based on the current commit status to obtain the synchronized source file and the synchronized target files for each version includes: When the current commit status is "new", retrieve the current commit content, create the same directory structure in the target repository, and write it to the target file; When the current commit content status is deleted, delete the content in the context line corresponding to the current commit content in the target repository; When the current submission status is "modified", check if the target file exists; if it does not exist, create it directly; if it exists, apply a patch to the target file based on the difference data; if the application is successful, write the merged content.

[0012] In an alternative approach, the method further includes: Record all operation details during the synchronization process and push them to the user interface in real time; The user interface displays a synchronization completion message and shows the complete log.

[0013] According to another aspect of the present invention, an intelligent synchronization device is provided, comprising: The acquisition module is used to acquire the synchronization request message sent by the user in the user operation interface; the synchronization request message includes information about the source file to be synchronized; the information about the source file to be synchronized includes the current commit content of the source file, source repository information and target repository information; The first determining module is used to determine the source file information and the target file information of each version corresponding to the source file based on the synchronization request information; the source file information includes the source file path and the current submission status; The comparison module is used to compare the current submission content of the source file with the content in the parent submission to obtain the difference data; The second determining module is used to determine the corresponding context line in the target file of each version based on the current submission content, the current submission content status, and the difference data; The synchronization module is used to perform synchronization operations on the context lines to obtain the synchronized source file and the synchronized target files of each version.

[0014] According to another aspect of the present invention, a computer device is provided, 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 executable instruction that causes the processor to perform the operation of the intelligent synchronization method.

[0015] According to another aspect of the present invention, a computer-readable storage medium is provided, the storage medium storing at least one executable instruction, which, when executed on a computer device, causes the computer device to perform the operation of the intelligent synchronization method.

[0016] This invention, through its embodiments, acquires synchronization request messages sent by users on user interfaces. These messages include information about source files to be synchronized, including the current commit content, source repository information, and target repository information. Based on the synchronization request information, the invention determines the source file information and target file information for each corresponding version. The source file information includes the source file path and the current commit status. Differences between the current commit content and the content of the parent commit are compared to obtain difference data. Based on the current commit content, the current commit status, and the difference data, the corresponding context lines in each version of the target file are determined. Synchronization is then performed on the context lines based on the current commit status, resulting in synchronized source files and synchronized target files for each version. This highly automated code synchronization significantly reduces manual intervention costs and improves synchronization efficiency. Furthermore, through intelligent difference analysis algorithms, it accurately identifies similar and differing parts of the source and target files, preserving differentiated content in the target repository and improving synchronization accuracy. It also provides incremental merging capabilities, calculating change patches based on Git version history and intelligently applying them to target files, reducing conflict rates and error rates.

[0017] The above description is merely an overview of the technical solutions of the embodiments of the present invention. In order to better understand the technical means of the embodiments of the present invention and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0018] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 A flowchart illustrating the intelligent synchronization method provided in an embodiment of the present invention is shown; Figure 2 A schematic diagram of the structure of the intelligent synchronization device provided in an embodiment of the present invention is shown; Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation

[0019] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0020] Figure 1 A flowchart of an intelligent synchronization method provided in an embodiment of the present invention is shown. This method is executed by a computer device. The computer device includes a personal computer, a desktop computer, a distributed device, a smart terminal, etc. The computer device uses a C / S (client / server) architecture and is developed based on the Node.js platform. It includes the following core component layers: (1) User interaction layer: a graphical user interface built on Web technology (Jade template engine, Bootstrap front-end framework), which allows users to access the system through a browser; (2) Communication layer: a real-time bidirectional communication mechanism based on Socket.IO, responsible for message passing and log pushing between the server and the client; (3) Application service layer: an HTTP server built on the Express.js framework, which processes API requests and executes business logic; (4) Git management layer: a Git operation interface encapsulated based on the Simple-Git library, responsible for repository access, commit parsing, file content acquisition, etc.; (5) Difference analysis layer: a text difference algorithm module based on the Diff library, responsible for calculating file change patches and application patches; (6) File system layer: a file read and write operation based on the Node.js native FS module, responsible for the creation, modification, and deletion of target repository files; (7) Data persistence layer: a repository configuration information management based on JSON file storage, using LocalStorage technology to record user operation history. Among them, such as Figure 1 As shown, the method includes the following steps: Step 110: Obtain the synchronization request message sent by the user in the user operation interface; the synchronization request message includes information about the source file that needs to be synchronized.

[0021] The information of the source files that need to be synchronized includes the current commit content of the source files, source repository information, and target repository information.

[0022] In this embodiment of the invention, before obtaining the synchronization request message sent by the user on the user operation interface, the method further includes: The system retrieves multiple Git repositories added by the user through the user interface and generates a Git repository list. The Git repository information includes the repository name, repository ID, and local repository path. The repository information is stored in a local file (repositories.json) in JSON format. The repository management module provides API interfaces for adding, deleting, and querying repositories. When adding a repository, the system verifies the path validity and the Git repository's legitimacy (checking if the .git directory exists). Specifically, the system receives the repository name and path entered by the user through the user interface, the application service layer receives the request, the repository management module verifies the path and Git repository, generates a unique ID and saves it to repositories.json, and finally returns a success response, displaying the new repository list on the user interface.

[0023] This includes obtaining synchronization request messages sent by the user on the user interface, including: This module retrieves the current commit content of the source file as displayed in the user interface. Specifically, when the user selects a source repository, the frontend sends a GET request to ` / api / commits / :repoId`. The commit history parsing module reads the source repository path, calls Simple-Git to retrieve the current commit list, and returns the current commit content in JSON format. This current commit content includes the commit hash, message, author, and date. The frontend renders the current commit list and displays it to the user, who then selects a specific commit. The module calls the `log()` method of the Simple-Git library to retrieve the N most recent commit records; parses the commit object, extracts the first line as the commit subject, formats the data, and returns it to the frontend. After the user selects a commit, the frontend sends a GET request to ` / api / commit / :repoId / :hash`. The file change analysis module calls the `git show --name-status` command, parses the output, extracts the source file path and status (A / M / D), and returns an array of file objects. The frontend renders a list of file checkboxes, and the user selects the files to be synchronized. Based on the current commit content of the source file, the module retrieves the target repository list corresponding to the source repository and returns the target repository list to the user.

[0024] Retrieve repository information for the target repositories selected by the user from the target repository list. Specifically, the user selects one or more target repositories on the interface, and the front-end collects a list of the selected target repository IDs.

[0025] Based on the current commit content of the source file, the source repository information, and the selected repositories to be synchronized from the repository list, a synchronization request message is generated. When the user clicks the "Start Synchronization" button, the frontend sends a POST / api / sync request, carrying the source repository ID, commit hash, file list, and target repository ID list. The application service layer verifies data integrity and immediately returns a sessionId and a success response. The backend then asynchronously executes the synchronization process.

[0026] In this embodiment, the user interface provides a user-friendly web interface for users to perform repository management, submission selection, file selection, synchronization operations, etc. Specifically, the Jade template engine is used to render the page structure; the Bootstrap framework is used to provide responsive layout and UI components; and JavaScript and the Socket.IO client are used to implement front-end and back-end interaction and real-time log display. Data flow: User interface → Sending HTTP requests or WebSocket messages → Back-end processing → Returning results or pushing logs → Front-end updating interface.

[0027] Step 120: Based on the synchronization request information, determine the source file information and the target file information of each version corresponding to the source file.

[0028] The source file information includes the source file path and the current submission status.

[0029] The source repository information includes the source repository name, source repository ID, and local repository path. The target repository information includes the target repository name, target repository ID, and local repository path.

[0030] In this embodiment, the source file information and the target file information of each version corresponding to the source file are obtained through the following steps: Based on the current commit content of the source file and the source repository information, query the source file path of the source file in the source repository.

[0031] Specifically, for the historical commit content of the source file, the user selects the source repository, the application service layer queries the path based on the repository ID, the commit history parsing module calls Git commands to obtain the commit list, formats the data, and returns it to the front end via an HTTP response.

[0032] This involves calling the `show()` method from the Simple-Git library to execute `git show`. <commit> : <filepath>The command retrieves a snapshot of the source files at the current commit moment; for source files that have been deleted, content retrieval is skipped. Data flow: The synchronization module requests the source file content, the source file content retrieval module executes the Git command, and returns a string representing the file content.

[0033] Based on the current submission content, the status of the current submission content is determined by matching the status code using a preset regular expression; the status code indicates that the current submission content status is any one of addition, deletion, modification, or renaming.

[0034] Output the source repository information, including the current submission status and the source file path. Based on the current submission content and target repository information, retrieve the target file information from the target repository.

[0035] Step 130: Compare the current submission content of the source file with the content of the parent submission to obtain the difference data.

[0036] Specifically, this involves retrieving the current commit content and the corresponding parent commit content of the source file. As mentioned earlier, this includes reading the commit history of the specified Git repository and extracting metadata such as the commit hash, commit message, author, and date of the content in the parent commit.

[0037] The source file path, the content of the parent commit, and the content of the current commit are input into the patch generation method of the Diff library to determine the difference data. The difference data includes the change operation information of the current commit to the source file, and the change operation information includes the change location and change content line by line. The change operations include addition, deletion, and modification. Specifically, step 1: Obtain the content of the source file in the current commit (currentContent) and the content in the parent commit (previousContent); step 2: Call the createPatch() method of the Diff library, input the file path, previousContent, and currentContent, and generate a Unified Diff Format patch; step 3: The patch describes the add, delete, and modify operations required from previousContent to currentContent, recording the change location and content line by line.

[0038] Step 140: Based on the current commit content, the current commit content status, and the difference data, determine the corresponding context lines in the target files of each version.

[0039] The calculated change patches are intelligently applied to files in the target repository, achieving incremental merging while preserving the differentiated content of the target repository. Specifically, the patch application algorithm utilizes a context matching mechanism to determine the context lines corresponding to the current commit content in each version of the target file, based on the current commit content, the current commit content status, and the difference data. Step 1: Read the current content (targetContent) of the corresponding file in the target repository; Step 2: Call the applyPatch() method of the Diff library, inputting targetContent and patch data; Step 3: The applyPatch() algorithm attempts to locate the specified context lines of the patch within targetContent and finds a matching position.

[0040] The patch application algorithm utilizes a context matching mechanism, which can tolerate differences between the target file and the source file in other locations. As long as the lines involved in the patch and their context can match, the patch can be successfully applied, thereby achieving the preservation of differences.

[0041] Step 150: Based on the current submission status, perform a synchronization operation on the context line to obtain the synchronized source file and the synchronized target files for each version.

[0042] The applyPatch() algorithm attempts to locate the context lines specified by the patch in targetContent. After finding a matching position, it executes the add, delete, and modify operations in the patch. If the patch is successfully applied, it returns the merged file content. If it fails (e.g., context mismatch), it returns false, and the system downgrades to a full file replacement strategy.

[0043] When the current commit status is "new", retrieve the current commit content, create the same directory structure in the target repository, and write it to the target file; When the current commit content status is deleted, delete the content in the context line corresponding to the current commit content in the target repository; When the current submission status is "modified", check if the target file exists; if it does not exist, create it directly; if it exists, apply a patch to the target file based on the difference data; if the application is successful, write the merged content.

[0044] Specifically, if the status is A (new): call the source file content retrieval module and execute `git show`. <commit> : <filepath>The process involves: retrieving the content of the source file; creating the directory structure for each target repository (fs.mkdirSync); writing to the file (fs.writeFileSync); and sending a "file added successfully" log. If the status is D (deleted): For each target repository, check if the target file exists; if it exists, delete it (fs.unlinkSync); send a "file deleted successfully" log. If the status is M (modified): Step A: Call the source file content retrieval module to obtain the content of the currently submitted source file (currentContent). Step B: Obtain the parent commit hash (git revparse) <commit> Step C: Call the source file content acquisition module to obtain the source file content (previousContent) of the parent commit; Step D: Call the difference patch calculation module to execute createPatch(filepath, previousContent, currentContent) to generate the change patch; For each target repository: Step E: Check if the target file exists; If not, create a directory and write currentContent, send "create file" log; If exists: Step F: Read the current content of the target file (targetContent); Step G: Compare targetContent and currentContent, if the same, skip, send "file is up-to-date" log; Step H: Call the intelligent patch application module to execute applyPatch(targetContent, patch); Step I: If applyPatch() returns the merged result string, write to the target file, send "intelligent update success" log; Step J: If applyPatch() returns false, execute the downgrade strategy, directly write currentContent, send "intelligent merge failed, full file replacement" warning log.

[0045] Through the above steps, the following effects are achieved: (1) Achieve highly automated code synchronization operation, significantly reduce manual intervention cost, and improve synchronization efficiency; (2) Through intelligent difference analysis algorithm, accurately identify the similar and different parts of source file and target file, retain the differentiated content of target repository, and improve synchronization accuracy; (3) Provide incremental merge capability, calculate change patch based on Git version history, and intelligently apply to target file, reduce conflict rate and error rate; (4) Support batch, multi-target synchronization operation, improve batch processing capability and system response speed, meet rapid iteration demand; (5) Generate detailed operation log and real-time feedback, enhance operation transparency and traceability, improve system reliability and maintainability.

[0046] ​In this embodiment of the invention, the Synchronization Execution Engine module coordinates the entire synchronization process and enables each module to complete batch and multi-target intelligent synchronization operations.

[0047] The synchronous execution engine module performs the following steps: Step 1: Receive the source repository ID, commit hash, file list, and target repository ID list selected by the user; Step 2: Verify the validity of the input data and query the warehouse configuration information; Step 3: Iterate through the file list and perform the following operations for each file: Step 3.1: Determine the processing strategy based on the file status (A / M / D); Step 3.2: If it is a new file (A), obtain the content of the source file, create the same directory structure in the target repository, and write it to the file; Step 3.3: If the deletion is (D), delete the corresponding file in the target repository; Step 3.4: If it is a modification (M), execute the smart merge process: Step 3.4.1: Check if the target file exists; if not, create it directly. Step 3.4.2: If it exists, call the difference patch calculation module to obtain the change patch; Step 3.4.3: Call the smart patch application module to attempt to apply the patch; Step 3.4.4: If the application succeeds, write the merged content; if it fails, record a warning log and perform a full file replacement. Step 4: Repeat step 3 for each target warehouse; Step 5: Push operation logs to the front end in real time via Socket.IO, including the currently processed file, repository, and status (success / warning / error); Step 6: After all files have been processed, send a synchronization completion event.

[0048] Data flow: User submits synchronization request → Application service layer receives and verifies → Synchronization execution engine module traverses files and target repository → Calls modules such as file content acquisition, difference calculation, and patch application → File system layer performs write operation → Log management module pushes logs → Front-end displays progress in real time.

[0049] The method further includes: Record all operation details during the synchronization process and push them to the user interface in real time; The user interface displays a synchronization completion message and shows the complete log.

[0050] The real-time log management module records all operation details during the synchronization process and pushes them to the front-end for display in real time via Socket.IO. Logs are generated as each module performs operations. The log management module formats the log objects and pushes them to the front-end via WebSocket, where they are displayed in real time. Specifically, a unique session ID (sessionId) is generated for each synchronization operation; a log object is generated for each operation step, containing the sessionId, log type (info / success / warning / error), and message content; the logs are pushed to all connected clients using the io.emit() method; and the front-end listens for log events through the Socket.IO client and dynamically updates the log list.

[0051] This invention, through its embodiments, acquires synchronization request messages sent by users on user interfaces. These messages include information about source files to be synchronized, including the current commit content, source repository information, and target repository information. Based on the synchronization request information, the invention determines the source file information and target file information for each corresponding version. The source file information includes the source file path and the current commit status. Differences between the current commit content and the content of the parent commit are compared to obtain difference data. Based on the current commit content, the current commit status, and the difference data, the corresponding context lines in each version of the target file are determined. Synchronization is then performed on the context lines based on the current commit status, resulting in synchronized source files and synchronized target files for each version. This highly automated code synchronization significantly reduces manual intervention costs and improves synchronization efficiency. Furthermore, through intelligent difference analysis algorithms, it accurately identifies similar and differing parts of the source and target files, preserving differentiated content in the target repository and improving synchronization accuracy. It also provides incremental merging capabilities, calculating change patches based on Git version history and intelligently applying them to target files, reducing conflict rates and error rates.

[0052] Figure 2 A schematic diagram of the structure of the intelligent synchronization device provided in an embodiment of the present invention is shown. Figure 2 As shown, the device 300 includes: The acquisition module 310 is used to acquire a synchronization request message sent by the user on the user operation interface; the synchronization request message includes information about the source file to be synchronized; the information about the source file to be synchronized includes the current commit content of the source file, source repository information and target repository information; The first determining module 320 is used to determine the source file information and the target file information of each version corresponding to the source file based on the synchronization request information; the source file information includes the source file path and the current submission status; Comparison module 330 is used to compare the current submission content of the source file with the content in the parent submission to obtain difference data; The second determining module 340 is used to determine the corresponding context line in the target file of each version based on the current submission content, the current submission content status and the difference data; The synchronization module 350 is used to perform synchronization operations on the context lines to obtain the synchronized source file and the synchronized target files of each version.

[0053] In one alternative embodiment, before acquiring the synchronization request message sent by the user on the user interface, the device further includes a warehouse management module, used for: Retrieve multiple Git repositories added by the user through the user interface and generate a list of Git repositories; the information of the Git repository includes the Git repository name, repository ID and local repository path; The step of obtaining the synchronization request message sent by the user in the user operation interface includes: Get the current submission content of the user to the source file in the user operation interface; Based on the current commit content of the source file, obtain the target repository list corresponding to the source repository, and return the target repository list to the user; Retrieve the repository information of the target repository selected by the user in the target repository list that needs to be synchronized; A synchronization request message is generated based on the current commit content of the source file, the source repository information, and the repository information selected from the repository list to be synchronized.

[0054] In one optional approach, the source repository information includes the source repository name, source repository ID, and source repository local repository path; the target repository information includes the target repository name, target repository ID, and target repository local repository path. The step of determining the source file information and the target file information for each version of the source file based on the synchronization request information further includes: Based on the current commit content of the source file and the source repository information, query the source file path of the source file in the source repository; Based on the current submission content, the status of the current submission content is determined by matching the status code using a preset regular expression; the status code indicates that the current submission content status is any one of addition, deletion, modification, or renaming. Output the source repository information, including the current submission status and the source file path. Based on the current submission content and target repository information, retrieve the target file information from the target repository.

[0055] In one alternative approach, the differences between the current commit content of the source file and the content of the parent commit are compared to obtain difference data, including: Retrieve the current commit content and the corresponding parent commit content of the source file; The source file path, the content of the parent commit, and the content of the current commit are input into the patch generation method of the Diff library to determine the difference data. The difference data includes the change operation information of the current commit to the source file, and the change operation information includes the change location and change content on a line-by-line basis. The change operation includes adding, deleting, and modifying.

[0056] In one optional approach, determining the corresponding context line in the target file for each version based on the current commit content, the current commit content status, and the difference data includes: By using a context matching mechanism through a patch application algorithm, the context line corresponding to the current commit content in the target file of each version is determined based on the current commit content, the current commit content status, and the difference data.

[0057] In one optional approach, the step of synchronizing the context lines based on the current commit status to obtain the synchronized source file and the synchronized target files for each version includes: When the current commit status is "new", retrieve the current commit content, create the same directory structure in the target repository, and write it to the target file; When the current commit content status is deleted, delete the content in the context line corresponding to the current commit content in the target repository; When the current submission status is "modified", check if the target file exists; if it does not exist, create it directly; if it exists, apply a patch to the target file based on the difference data; if the application is successful, write the merged content.

[0058] In an alternative embodiment, the device further includes a logging module for: Record all operation details during the synchronization process and push them to the user interface in real time; The user interface displays a synchronization completion message and shows the complete log.

[0059] The working process of the device in this embodiment is largely the same as the specific steps of the aforementioned method, and will not be repeated here.

[0060] This invention, through its embodiments, acquires synchronization request messages sent by users on user interfaces. These messages include information about source files to be synchronized, including the current commit content, source repository information, and target repository information. Based on the synchronization request information, the invention determines the source file information and target file information for each corresponding version. The source file information includes the source file path and the current commit status. Differences between the current commit content and the content of the parent commit are compared to obtain difference data. Based on the current commit content, the current commit status, and the difference data, the corresponding context lines in each version of the target file are determined. Synchronization is then performed on the context lines based on the current commit status, resulting in synchronized source files and synchronized target files for each version. This highly automated code synchronization significantly reduces manual intervention costs and improves synchronization efficiency. Furthermore, through intelligent difference analysis algorithms, it accurately identifies similar and differing parts of the source and target files, preserving differentiated content in the target repository and improving synchronization accuracy. It also provides incremental merging capabilities, calculating change patches based on Git version history and intelligently applying them to target files, reducing conflict rates and error rates.

[0061] Figure 3 The diagram shows a structural schematic of a computer device provided in an embodiment of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the computer device.

[0062] like Figure 3 As shown, the computer device may include: a processor 402, a communications interface 404, a memory 406, and a communications bus 408.

[0063] The processor 402, communication interface 404, and memory 406 communicate with each other via communication bus 408. Communication interface 404 is used to communicate with other network elements such as clients or other servers. The processor 402 executes program 410, specifically performing the relevant steps described above in the intelligent synchronization method embodiment.

[0064] Specifically, program 410 may include program code, which includes computer-executable instructions.

[0065] Processor 402 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The computer device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0066] Memory 406 is used to store program 410. Memory 406 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0067] Specifically, program 410 can be called by processor 402 to cause the computer device to perform the following operations: Obtain a synchronization request message sent by the user in the user operation interface; the synchronization request message includes information about the source file to be synchronized; the information about the source file to be synchronized includes the current commit content of the source file, source repository information and target repository information; Based on the synchronization request information, the source file information and the target file information for each version of the source file are determined; the source file information includes the source file path and the current submission status; Compare the current commit content of the source file with the content of the parent commit to obtain the difference data; Based on the current commit content, the current commit content status, and the difference data, determine the corresponding context lines in the target files of each version; Based on the current submission status, the context line is synchronized to obtain the synchronized source file and the synchronized target files for each version.

[0068] In one alternative approach, prior to obtaining the synchronization request message sent by the user on the user interface, the method includes: Retrieve multiple Git repositories added by the user through the user interface and generate a list of Git repositories; the information of the Git repository includes the Git repository name, repository ID and local repository path; The step of obtaining the synchronization request message sent by the user in the user operation interface includes: Get the current submission content of the user to the source file in the user operation interface; Based on the current commit content of the source file, obtain the target repository list corresponding to the source repository, and return the target repository list to the user; Retrieve the repository information of the target repository selected by the user in the target repository list that needs to be synchronized; A synchronization request message is generated based on the current commit content of the source file, the source repository information, and the repository information selected from the repository list to be synchronized.

[0069] In one optional approach, the source repository information includes the source repository name, source repository ID, and source repository local repository path; the target repository information includes the target repository name, target repository ID, and target repository local repository path. The step of determining the source file information and the target file information for each version of the source file based on the synchronization request information further includes: Based on the current commit content of the source file and the source repository information, query the source file path of the source file in the source repository; Based on the current submission content, the status of the current submission content is determined by matching the status code using a preset regular expression; the status code indicates that the current submission content status is any one of addition, deletion, modification, or renaming. Output the source repository information, including the current submission status and the source file path. Based on the current submission content and target repository information, retrieve the target file information from the target repository.

[0070] In one alternative approach, the differences between the current commit content of the source file and the content of the parent commit are compared to obtain difference data, including: Retrieve the current commit content and the corresponding parent commit content of the source file; The source file path, the content of the parent commit, and the content of the current commit are input into the patch generation method of the Diff library to determine the difference data. The difference data includes the change operation information of the current commit to the source file, and the change operation information includes the change location and change content on a line-by-line basis. The change operation includes adding, deleting, and modifying.

[0071] In one optional approach, determining the corresponding context line in the target file for each version based on the current commit content, the current commit content status, and the difference data includes: By using a context matching mechanism through a patch application algorithm, the context line corresponding to the current commit content in the target file of each version is determined based on the current commit content, the current commit content status, and the difference data.

[0072] In one optional approach, the step of synchronizing the context lines based on the current commit status to obtain the synchronized source file and the synchronized target files for each version includes: When the current commit status is "new", retrieve the current commit content, create the same directory structure in the target repository, and write it to the target file; When the current commit content status is deleted, delete the content in the context line corresponding to the current commit content in the target repository; When the current submission status is "modified", check if the target file exists; if it does not exist, create it directly; if it exists, apply a patch to the target file based on the difference data; if the application is successful, write the merged content.

[0073] In an alternative approach, the method further includes: Record all operation details during the synchronization process and push them to the user interface in real time; The user interface displays a synchronization completion message and shows the complete log.

[0074] This invention, through its embodiments, acquires synchronization request messages sent by users on user interfaces. These messages include information about source files to be synchronized, including the current commit content, source repository information, and target repository information. Based on the synchronization request information, the invention determines the source file information and target file information for each corresponding version. The source file information includes the source file path and the current commit status. Differences between the current commit content and the content of the parent commit are compared to obtain difference data. Based on the current commit content, the current commit status, and the difference data, the corresponding context lines in each version of the target file are determined. Synchronization is then performed on the context lines based on the current commit status, resulting in synchronized source files and synchronized target files for each version. This highly automated code synchronization significantly reduces manual intervention costs and improves synchronization efficiency. Furthermore, through intelligent difference analysis algorithms, it accurately identifies similar and differing parts of the source and target files, preserving differentiated content in the target repository and improving synchronization accuracy. It also provides incremental merging capabilities, calculating change patches based on Git version history and intelligently applying them to target files, reducing conflict rates and error rates.

[0075] This invention provides a computer-readable storage medium storing at least one executable instruction that, when executed on a computer device, causes the computer device to perform the intelligent synchronization method in any of the above method embodiments.

[0076] Executable instructions can be used to cause computer devices to perform the following operations: Obtain a synchronization request message sent by the user in the user operation interface; the synchronization request message includes information about the source file to be synchronized; the information about the source file to be synchronized includes the current commit content of the source file, source repository information and target repository information; Based on the synchronization request information, the source file information and the target file information for each version of the source file are determined; the source file information includes the source file path and the current submission status; Compare the current commit content of the source file with the content of the parent commit to obtain the difference data; Based on the current commit content, the current commit content status, and the difference data, determine the corresponding context lines in the target files of each version; Based on the current submission status, the context line is synchronized to obtain the synchronized source file and the synchronized target files for each version.

[0077] In one alternative approach, prior to obtaining the synchronization request message sent by the user on the user interface, the method includes: Retrieve multiple Git repositories added by the user through the user interface and generate a list of Git repositories; the information of the Git repository includes the Git repository name, repository ID and local repository path; The step of obtaining the synchronization request message sent by the user in the user operation interface includes: Get the current submission content of the user to the source file in the user operation interface; Based on the current commit content of the source file, obtain the target repository list corresponding to the source repository, and return the target repository list to the user; Retrieve the repository information of the target repository selected by the user in the target repository list that needs to be synchronized; A synchronization request message is generated based on the current commit content of the source file, the source repository information, and the repository information selected from the repository list to be synchronized.

[0078] In one optional approach, the source repository information includes the source repository name, source repository ID, and source repository local repository path; the target repository information includes the target repository name, target repository ID, and target repository local repository path. The step of determining the source file information and the target file information for each version of the source file based on the synchronization request information further includes: Based on the current commit content of the source file and the source repository information, query the source file path of the source file in the source repository; Based on the current submission content, the status of the current submission content is determined by matching the status code using a preset regular expression; the status code indicates that the current submission content status is any one of addition, deletion, modification, or renaming. Output the source repository information, including the current submission status and the source file path. Based on the current submission content and target repository information, retrieve the target file information from the target repository.

[0079] In one alternative approach, the differences between the current commit content of the source file and the content of the parent commit are compared to obtain difference data, including: Retrieve the current commit content and the corresponding parent commit content of the source file; The source file path, the content of the parent commit, and the content of the current commit are input into the patch generation method of the Diff library to determine the difference data. The difference data includes the change operation information of the current commit to the source file, and the change operation information includes the change location and change content on a line-by-line basis. The change operation includes adding, deleting, and modifying.

[0080] In one optional approach, determining the corresponding context line in the target file for each version based on the current commit content, the current commit content status, and the difference data includes: By using a context matching mechanism through a patch application algorithm, the context line corresponding to the current commit content in the target file of each version is determined based on the current commit content, the current commit content status, and the difference data.

[0081] In one optional approach, the step of synchronizing the context lines based on the current commit status to obtain the synchronized source file and the synchronized target files for each version includes: When the current commit status is "new", retrieve the current commit content, create the same directory structure in the target repository, and write it to the target file; When the current commit content status is deleted, delete the content in the context line corresponding to the current commit content in the target repository; When the current submission status is "modified", check if the target file exists; if it does not exist, create it directly; if it exists, apply a patch to the target file based on the difference data; if the application is successful, write the merged content.

[0082] In an alternative approach, the method further includes: Record all operation details during the synchronization process and push them to the user interface in real time; The user interface displays a synchronization completion message and shows the complete log.

[0083] This invention, through its embodiments, acquires synchronization request messages sent by users on user interfaces. These messages include information about source files to be synchronized, including the current commit content, source repository information, and target repository information. Based on the synchronization request information, the invention determines the source file information and target file information for each corresponding version. The source file information includes the source file path and the current commit status. Differences between the current commit content and the content of the parent commit are compared to obtain difference data. Based on the current commit content, the current commit status, and the difference data, the corresponding context lines in each version of the target file are determined. Synchronization is then performed on the context lines based on the current commit status, resulting in synchronized source files and synchronized target files for each version. This highly automated code synchronization significantly reduces manual intervention costs and improves synchronization efficiency. Furthermore, through intelligent difference analysis algorithms, it accurately identifies similar and differing parts of the source and target files, preserving differentiated content in the target repository and improving synchronization accuracy. It also provides incremental merging capabilities, calculating change patches based on Git version history and intelligently applying them to target files, reducing conflict rates and error rates.

[0084] This invention provides an intelligent synchronization device for executing the above-described intelligent synchronization method.

[0085] This invention provides a computer program that can be invoked by a processor to cause a computer device to execute the intelligent synchronization method in any of the above method embodiments.

[0086] This invention provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions that, when executed on a computer, cause the computer to perform the intelligent synchronization method in any of the above method embodiments.

[0087] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of the present invention are not directed to any particular programming language. It should be understood that the content of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0088] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0089] Similarly, it should be understood that, in order to streamline the invention and aid in understanding one or more of the various aspects of the invention, features of the embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the above description of exemplary embodiments of the invention. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.

[0090] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0091] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.< / commit> < / filepath> < / commit> < / filepath> < / commit>

Claims

1. An intelligent synchronization method, characterized in that, The method includes: Obtain a synchronization request message sent by the user in the user operation interface; the synchronization request message includes information about the source file to be synchronized; the information about the source file to be synchronized includes the current commit content of the source file, source repository information and target repository information; Based on the synchronization request information, the source file information and the target file information for each version of the source file are determined; the source file information includes the source file path and the current submission status; Compare the current commit content of the source file with the content of the parent commit to obtain the difference data; Based on the current commit content, the current commit content status, and the difference data, determine the corresponding context lines in the target files of each version; Based on the current submission status, the context line is synchronized to obtain the synchronized source file and the synchronized target files for each version.

2. The method according to claim 1, characterized in that, Before obtaining the synchronization request message sent by the user on the user interface, the method further includes: Retrieve multiple Git repositories added by the user through the user interface and generate a list of Git repositories; the information of the Git repository includes the Git repository name, repository ID and local repository path; The step of obtaining the synchronization request message sent by the user in the user operation interface includes: Get the current submission content of the user to the source file in the user operation interface; Based on the current commit content of the source file, obtain the target repository list corresponding to the source repository, and return the target repository list to the user; Retrieve the repository information of the target repository selected by the user in the target repository list that needs to be synchronized; A synchronization request message is generated based on the current commit content of the source file, the source repository information, and the repository information selected from the repository list to be synchronized.

3. The method according to claim 2, characterized in that, The source repository information includes the source repository name, source repository ID, and local repository path; the target repository information includes the target repository name, target repository ID, and local repository path. The step of determining the source file information and the target file information for each version of the source file based on the synchronization request information further includes: Based on the current commit content of the source file and the source repository information, query the source file path of the source file in the source repository; Based on the current submission content, the status of the current submission content is determined by matching the status code using a preset regular expression; the status code indicates that the current submission content status is any one of addition, deletion, modification, or renaming. Output the source repository information, including the current submission status and the source file path. Based on the current submission content and target repository information, retrieve the target file information from the target repository.

4. The method according to claim 3, characterized in that, Compare the current commit content of the source file with the content of the parent commit to obtain difference data, including: Retrieve the current commit content and the corresponding parent commit content of the source file; The source file path, the content of the parent commit, and the content of the current commit are input into the patch generation method of the Diff library to determine the difference data. The difference data includes the change operation information of the current commit to the source file, and the change operation information includes the change location and change content on a line-by-line basis. The change operation includes adding, deleting, and modifying.

5. The method according to any one of claims 1-3, characterized in that, The step of determining the corresponding context line in the target file for each version based on the current commit content, the current commit content status, and the difference data includes: By using a context matching mechanism through a patch application algorithm, the context line corresponding to the current commit content in the target file of each version is determined based on the current commit content, the current commit content status, and the difference data.

6. The method according to any one of claims 1-3, characterized in that, The step of synchronizing the context lines based on the current submission status to obtain the synchronized source file and the synchronized target files for each version includes: When the current commit status is "new", retrieve the current commit content, create the same directory structure in the target repository, and write it to the target file; When the current commit content status is deleted, delete the content in the context line corresponding to the current commit content in the target repository; When the current submission status is "modified", check if the target file exists; if it does not exist, create it directly; if it exists, apply a patch to the target file based on the difference data; if the application is successful, write the merged content.

7. The method according to any one of claims 1-3, characterized in that, The method further includes: Record all operation details during the synchronization process and push them to the user interface in real time; The user interface displays a synchronization completion message and shows the complete log.

8. An intelligent synchronization device, characterized in that, The device includes: The acquisition module is used to acquire the synchronization request message sent by the user in the user operation interface; the synchronization request message includes information about the source file to be synchronized; the information about the source file to be synchronized includes the current commit content of the source file, source repository information and target repository information; The first determining module is used to determine the source file information and the target file information of each version corresponding to the source file based on the synchronization request information; the source file information includes the source file path and the current submission status; The comparison module is used to compare the current submission content of the source file with the content in the parent submission to obtain the difference data; The second determining module is used to determine the corresponding context line in the target file of each version based on the current commit content, the current commit content status, and the difference data. The synchronization module is used to perform synchronization operations on the context lines to obtain the synchronized source file and the synchronized target files of each version.

9. A computer device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the operation of the intelligent synchronization method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The storage medium stores at least one executable instruction, which, when executed on a computer device, causes the computer device to perform the operation of the intelligent synchronization method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Synchronization method and device of code management system, storage medium and terminal

    CN109725927A

  • Code synchronization method and device, equipment, storage medium and program

    CN117435203A