A method for quickly building a web-based backend management system project based on git
By establishing a unified template project on gitlab and using git merge technology, the problem of low copy and update efficiency of the backend management system under the traditional development model is solved, rapid and stable framework iteration and update are achieved, and development costs and risks are reduced.
Patent Information
- Application Number
- CN202410087506.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-22
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-01-22
AI Technical Summary
Under the traditional development model, the copying and updating of the backend management system are inefficient and error-prone, and manual comparison and copying of codes are required when updating the public framework. Especially when there are multiple different versions of the template, the process is complex and time-consuming, and lacks direct , efficient and stable way.
By establishing a unified template project on GitLab, the differentiated configuration is extracted and stored in the project environment configuration file, git merge is used instead of manual replacement, npm script is encapsulated for update synchronization, and compressed commit is used to avoid contamination of historical submission records.
It improves the efficiency of establishing multiple homogeneous systems, reduces development thresholds and manual comparison risks, enables rapid and stable framework iteration and updates, and reduces development costs.
Smart Images

Figure CN118012486B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of version control, and in particular to a method for quickly constructing a web-side backend management system project based on git. Background Art
[0002] In the daily operation of an enterprise, the backend management system is a vital part, which supports the core business operation of the entire enterprise. However, with the continuous expansion and diversification of the enterprise's business, it is often necessary to create multiple backend management systems for different business lines or projects. Although these systems have similar frameworks, such as login, authentication, menu bar, and request encapsulation function modules, there are many differences in details.
[0003] In the traditional development model, developers usually copy an existing backend management system template and then modify it one by one according to the needs of the new system. This method is not only inefficient, but also prone to errors. Because even a small change may affect the entire system, causing problems in other codes. What's worse, once there is any update or fix at the public framework level, developers need to manually compare the old and new codes, copy and paste the updated code into each subsystem. Especially when there are multiple different versions of the template, this process becomes extremely complicated and time-consuming, lacking a direct, efficient and stable way to update.
[0004] This inefficient development method not only affects the project progress and increases the development cost, but also may lead to unstable software quality. Therefore, enterprises are in urgent need of a more efficient and stable method to quickly build these backend management systems with similar frameworks but different details. Summary of the invention
[0005] 1. Technical issues to be resolved
[0006] In view of the deficiencies in the prior art, the present invention provides a method for quickly building a web-side backend management system project based on git, which solves the problems raised in the above background technology.
[0007] (II) Technical solution
[0008] To achieve the above purpose, the present invention is implemented through the following technical solutions: a method for quickly building a web-side backend management system project based on git, including establishing a template project part: extracting differentiated configurations from existing logic codes and storing them in project environment configuration files; establishing a unified template project on gitlab and maintaining tag records of corresponding versions; merging the code of the template project warehouse into the current subsystem project by cross-git warehouse source. Establishment and update of subsystems: adding new business subsystems; synchronous template project updates.
[0009] Preferably, a unified template project is established. By creating a unified template project for the project, a unified framework code source is provided for each subsystem. In the template project, maintenance actions for version numbers and tags are added so that when creating a new system project, version codes of different stages can be downloaded from the corresponding tags according to specific needs. This solves the problem of establishing subsystems with different stage requirements during the framework iteration process. At the same time, the version number can be used as an effective guide for difference comparison, helping developers to determine whether an update is needed and the cost of the update.
[0010] Preferably, differentiated configurations are extracted and individual environment variables are configured at a unified entrance to complete the initialization of different project projects. There is no need to go deep into the system code and understand the operating logic before making modifications. This improves the collaborative efficiency of batch development and lowers the threshold requirements for subsystem developers.
[0011] Preferably, an encapsulated npm script is used for update synchronization. The npm script is encapsulated in the subsystem to perform update synchronization operations on the template project. The git merge method is used instead of manual replacement. The git merge code comparison function is used to make it stable and controllable. When there are different changes in the same code, they are presented in the form of conflicts, which greatly reduces the potential risks brought by manual comparison.
[0012] Preferably, a compressed commit is used during update merging, that is, only one commit of the merge (template) type is retained in the commit record, effectively preventing the historical commit record of the template update from polluting the subsystem.
[0013] (III) Beneficial effects
[0014] The present invention provides a method for quickly constructing a web-side backend management system project based on git.
[0015] It has the following beneficial effects:
[0016] 1. This solution establishes a unified template project for the project as the source of framework code, and adds maintenance actions for version numbers and tags. When creating a new system project, you can download version codes of different stages from the corresponding tags according to specific needs, which solves the problem of different stage requirements for establishing subsystems during the framework iteration process. At the same time, the version number can be used as an effective guide for difference comparison, helping developers determine whether updates are needed and the cost of updates;
[0017] 2. This solution abstracts away the differentiated configuration within the project. You only need to configure individual environment variables at a unified entrance to complete the initialization of different project projects. There is no need to go deep into the system code and understand the operation logic before making modifications. This improves the collaborative efficiency of batch development and reduces the threshold requirements for subsystem developers accordingly.
[0018] 3. This solution can update and synchronize the template project through the encapsulated npm script in the subsystem, using git merge instead of manual replacement. The code comparison function of git merge is used to make it stable and controllable. Different changes to the same code will be presented in the form of conflicts, greatly reducing the potential risks brought by manual comparison;
[0019] 4. This solution uses compressed commit for update and merge. Only one commit of merge(template) type will be retained in the commit record, effectively avoiding the pollution of subsystem by historical commit records of template updates.
[0020] In general, this method can effectively improve the efficiency of establishing multiple homogeneous systems, while avoiding the problem of omissions that may easily occur in manual comparison. It allows developers to enter the subsystem development work at a low cost and complete rapid output without having to understand and develop at the framework level. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0022] Figure 2 This is a flow chart of the actions of establishing a subsystem and updating a framework version of the present invention. DETAILED DESCRIPTION
[0023] In order to make the purpose, 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 in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0024] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0025] The embodiment of the present invention provides a method for quickly building a web-side backend management system project based on git, such as Figure 1-2 As shown, including:
[0026] Extract differentiated configurations from existing logic codes and store them in project environment configuration files. Differentiated configurations include system ID, request address, and authentication method, which are extracted from logic codes as environment variables. Environment variables are uniformly placed in .env files. Modify as needed when subsystems are initialized to meet differentiated needs.
[0027] A unified template project is established on gitlab, and the tag records of the corresponding versions are maintained. Functional changes at the framework level are performed on the template project. Each time a new version is released, the corresponding version number is updated through the npm publish command and a tag record is generated. The version number is updated according to the industry-wide standard Major.Minor.Patch. Large-scale reconstruction or destructive changes will be reflected in the first major version number Major, and recorded in the version parameter of the package.json file. Before the subsystem is updated, the difference in version numbers can be used to determine the change cost and compatibility risk of this update.
[0028] Merge the code of the template project repository into the current subsystem project through cross-git repository source, add relevant npm scripts, allow cross-remote merge through git commands and special parameters, add a temporary remote repository as another remote of the current repository; use compression parameters to treat all changes as a new mergecommit each time to avoid the template's commit records from polluting existing projects, and allow merging of code that has no history related to the current repository after obtaining the latest content of the remote repository, compressing all differences into a single commit; remove the added temporary remote repository.
[0029] Add a new business subsystem. When you need to add a new business subsystem, download the source code zip file from the tag record corresponding to the current or required version of the template project; use the zip file to decompress the source code, perform git-related initialization and remote association; follow the instructions in the readme file to find the env file entry to modify the required configuration parameters to adapt to different scenario requirements; and carry out business development normally.
[0030] Synchronize template project updates. When the subsystem needs to synchronize template project updates, clean up the existing git workspace and create a new update branch for update merging actions; run the internally encapsulated npm command: merge the processed update branch into the required branch to complete the update; and carry out business development normally.
[0031] The specific steps of running the internally encapsulated npm command are: setting the template git remote source; obtaining remote updates of the template source; compressing and merging the template source master branch into the current branch; handling merge conflicts first if there are any, modifying and updating the business content that needs to be modified, and completing the submission; removing the template source.
[0032] As the core method of this embodiment, different from the traditional manual update mode, the code of the template project repository is merged into the current subsystem project by cross-git repository source. The four specifically encapsulated commands can be:
[0033] "temp-add":"git remote add temp_origin{template remote warehouse address}"
[0034] "temp-fetch":"git fetch temp_origin master"
[0035] "temp-merge":"git merge-m'merge(template):update squash'temp_origin / master--allow-unrelated-histories--squash"
[0036] "temp-remove":"git remote remove temp_origin"
[0037] The temp-add command adds the template remote repository as another remote of the current repository, named temp_origin; the temp-fetch command obtains the latest content of the remote repository master branch; the temp-merge command is the command for the actual merge operation, using the parameter --allow-unrelated-histories to allow git to merge source codes that are not historically related, and the parameter --squash to compress all differences as a commit to avoid the template's commit records from polluting existing projects, while quickly specifying the commit information type as merge(template) for easy reference; finally, the temp-remove command is used to remove the remote source added by the temp-add command without interfering with the subsequent normal submission and push of the subsystem.
[0038] At the same time, releasing the framework part of the template project as a cli scaffold can also achieve a similar rapid output effect, but the update will be more troublesome than this method, which is suitable for scenarios where the framework is completely stable and no longer iterated; in addition, the single warehouse multi-project management mode of monorepo can also be used as an alternative, but it has higher requirements for the overall architectural design, and will also bring derivative problems such as permission granularity, code and public dependency management.
[0039] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for quickly building a web-side backend management system project based on git, characterized in that: include: Create a template project: S101. Extract differentiated configurations from existing logic codes and store them in project environment configuration files; S1011, the differentiated configuration includes system ID, request address and authentication method, which are extracted from the logic code as environment variables; S1012, placing the environment variables uniformly in a .env file; S1013. Perform on-demand modifications during subsystem initialization to meet differentiated needs; S102. Create a unified template project on gitlab and maintain the tag records of the corresponding versions; S1021. Functional changes at the framework level are performed on the template project. Each time a new version is released, the corresponding version number is updated through the npm publish command and a tag record is generated; S1022, the version number is updated according to the industry common standard Major.Minor.Patch as a rule; S1023. Scaled reconstruction or destructive changes will be reflected in the first major version number Major, and recorded in the version parameter of the package.json file; S1024. Before the subsystem performs an update operation, the change cost and compatibility risk of the update are determined by the difference in version numbers; S103, merging the code of the template project repository into the current subsystem project by cross-git repository source; S1031. Added relevant npm script, allowing it to merge across remotes through git commands and parameters, adding a temporary remote warehouse as another remote of the current warehouse. The four specific encapsulated commands are: "temp-add":"git remote add temp_origin{template remote warehouse address}" "temp-fetch":"git fetch temp_origin master" "temp-merge":"git merge-m'merge(template):update squash'temp_origin / master--allow-unrelated-histories--squash" "temp-remove":"git remote remove temp_origin", The temp-add command adds the template remote repository as another remote of the current repository, named temp_origin. The temp-fetch command obtains the latest content of the remote repository master branch. The temp-merge command is the actual merge command. The parameter --allow-unrelated-histories is used to allow git to merge unrelated historical source codes. The parameter --squash is used to compress all differences as a commit to avoid the template commit record from polluting the existing project. At the same time, the commit information type is quickly specified as merge (template) for easy reference. Finally, the temp-remove command is used to remove the remote source added by the temp-add command, which does not interfere with the subsequent normal submission and push of the subsystem. S1032, using compression parameters, each time all changes are treated as a new merge commit, to avoid the template commit record from polluting the existing project, after obtaining the latest content of the remote repository, it is allowed to merge the code that has no history related to the current repository, and all differences are compressed into a single commit; S1033. Remove the added temporary remote warehouse; Subsystem establishment: S204, adding a new business subsystem; When a new business subsystem needs to be added, S2041. Download the source code zip file from the tag record corresponding to the current or required version of the template project; S2042. Use the zip file to decompress the source code and perform git-related initialization and remote association; S2043. Follow the instructions in the readme file to find the env file entry and modify the required configuration parameters to meet the needs of different scenarios; S2044, carry out business development normally; Subsystem updates: S205, synchronous template project update; When the subsystem needs to synchronize template project updates, S2051. Clean up the existing git workspace and create a new update branch for update and merge actions; S2052, run the internally packaged npm command; S20521, set template git remote source; S20522, obtain template source remote update; S20523. Compress and merge the template source master branch into the current branch; S20524. If there is a merge conflict, the merge conflict is handled first, and the business content that needs to be modified is modified and updated, and the submission is completed; S20525, remove template source; S2053, merging the processed update branch into the required branch to complete the update; S2054. Carry out business development as normal.
Citation Information
Patent Citations
A git-based code distribution system
CN109522025A
Code warehouse management method and system applied to chip field
CN114880227A
