CN114528008A - Code control method, device and medium based on distributed version control system - Google Patents
Code control method, device and medium based on distributed version control system Download PDFInfo
- Publication number
- CN114528008A CN114528008A CN202210104331.4A CN202210104331A CN114528008A CN 114528008 A CN114528008 A CN 114528008A CN 202210104331 A CN202210104331 A CN 202210104331A CN 114528008 A CN114528008 A CN 114528008A
- Authority
- CN
- China
- Prior art keywords
- branch
- code
- development
- control system
- feature
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 42
- 238000011161 development Methods 0.000 claims abstract description 51
- 238000012552 review Methods 0.000 claims abstract description 21
- 238000011156 evaluation Methods 0.000 claims abstract description 4
- 238000007726 management method Methods 0.000 claims description 22
- 230000008569 process Effects 0.000 claims description 9
- 238000004422 calculation algorithm Methods 0.000 claims description 8
- 238000004590 computer program Methods 0.000 claims description 8
- 238000010367 cloning Methods 0.000 claims description 3
- 238000012550 audit Methods 0.000 claims description 2
- 238000004891 communication Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 101100217298 Mus musculus Aspm gene Proteins 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 229910002056 binary alloy Inorganic materials 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000036541 health Effects 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012384 transportation and delivery Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention relates to a code control method, equipment and a medium based on a distributed version control system, wherein the method comprises the following steps: code submission is performed based on a distributed version control system Git: the project source codes are cloned to the local, a local user branch is created, after the development is completed, development files are submitted and pushed to a remote user branch, and branch combination requests MR are submitted in Gitlab and review terminals are appointed; code review: the examination terminal evaluates the submitted codes and puts forward an evaluation suggestion, if the code examination is passed, the codes are merged into a feature branch, and if the codes are not passed, the branch merging request MR is closed; the developer optimizes or modifies the codes according to the review opinions and submits the development files again until the review is passed; version tracking: marking a mark on the feature branch after the iterative development is finished, marking a version number, and pushing the label to a far end; merging the feature branch to a develop branch. Compared with the prior art, the method has the advantages of off-line work and high code auditing efficiency.
Description
Technical Field
The present invention relates to the field of code management and control technologies, and in particular, to a code management and control method, device, and medium based on a distributed version control system.
Background
The version management can ensure to complete centralized and unified management in space, and the problems of consistency and redundancy are solved. The whole-time tracking and recording tool can automatically record each change detail in the development process and different versions in different periods so as to represent the software and related documents in different stages and perform differential analysis, and perform revocable modification on software codes so as to summarize the modification made by different developers and assist in coordinating and managing a software development team.
The code review and review is a very necessary link for a development team, and can effectively improve the product delivery quality and the development process efficiency. After the developer submits the MR, the project author must first Review the code and then decide whether to merge the code into the repository, and code that has not been reviewed cannot be merged into the repository. However, many development teams do not develop the project or still adopt an offline group and centralized review code examination mode. This approach is not only inefficient, but also fails to find problems in time and correct code problems in time.
Disclosure of Invention
The invention aims to overcome the defects in the prior art and provides a code management and control method, equipment and medium which can work offline and have high code auditing efficiency and are based on a distributed version control system.
The purpose of the invention can be realized by the following technical scheme:
according to a first aspect of the present invention, there is provided a code management and control method based on a distributed version control system, the method including the following steps:
s1, when a new task is iterated, building a feature branch from the develop branch based on a distributed version control system Git, and creating a user branch from the feature branch;
s2, code submission: cloning the project source code to the local, and creating a local user branch; after the development is completed, submitting a development file and pushing the development file to a remote user branch, submitting a branch combination request MR in Gitlab and designating an examination terminal;
s3, code examination: the examination terminal evaluates the submitted codes and puts forward an evaluation suggestion, if the code examination is passed, the codes are merged into a feature branch, and if the codes are not passed, the branch merging request MR is closed; the developer optimizes or modifies the codes according to the review opinions and submits the development files again until the review is passed;
s4, version tracking: marking a mark on the feature branch after the iterative development is finished, marking a version number, and pushing the label to a far end;
s5, merging the feature branch into the develop branch.
Preferably, a feature branch is newly established in step S1, and specifically:
and (3) locally establishing a feature branch through a git command and then pushing the feature branch to a remote end or directly establishing a feature branch on a branch management interface of the Gitlab, and locally obtaining the feature branch from the remote end.
Preferably, in step S2, submitting the branch merge request MR and designating the review terminal in Gitlab, the specific process is as follows:
opening a remote warehouse, creating a branch merging request MR, selecting the branch needing to create the branch merging request MR and the branch needing to be merged, and designating an examination terminal.
Preferably, each time the development file is submitted, a unique version number commit id is generated.
Preferably, the version number commit id is generated by using the SHA-1 algorithm.
Preferably, the distributed version control system Git adopts a key-value pair database, and returns a hash key for retrieving any content when the value is inserted into the database; the content in each code version is stored in the database.
Preferably, each development branch is associated with a tree object, the tree object stores all file names under the current development branch, and corresponding Key values and references of other tree objects, and after the development is completed, the development file is added to the cache region.
Preferably, each submission of the file is a snapshot of the current version, the snapshot including the top-level tree object, the what was submitted last time, the submitter user name and the mailbox.
According to a second aspect of the invention, there is provided an electronic device comprising a memory having stored thereon a computer program and a processor implementing any of the methods when the program is executed.
According to a third aspect of the invention, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any one of the preceding claims.
Compared with the prior art, the invention has the following advantages:
1) according to the code control method, each developer creates a user branch on a feature branch, submits the user branch, inspects codes by introducing a branch merging request MR function of Gitlab, and can merge the codes to a remote feature branch after the inspection is passed; the codes are checked on line, so that the code is checked and rechecked conveniently, and a reviewer checks the codes and can make comments at any time, so that certain codes can become better, and the overall health condition of the code library can be ensured to be improved continuously along with time;
2) the code development can work off line, most operations are finished locally, only the version submitted to feature branch by the user branch needs to be submitted to a centralized code management server in the center, and interaction with the centralized code management server is not needed, so that the pressure of a public server is reduced;
3) generating a unique version number commit id according to an SHA-1 algorithm every time of submission, so that the record of submission is convenient to track, and the version is convenient to manage;
4) the method of the invention can establish a plurality of local branches, can be completed only by command operation, does not need to establish redundant catalogues and activities, and is more convenient for the management and operation of the branches.
Drawings
FIG. 1 is a flow chart of a method of the present invention;
FIG. 2 is a flow chart of the present invention for creating a personal development branch on a development principal branch;
fig. 3 is a workflow diagram of a distributed version control system.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, shall fall within the scope of protection of the present invention.
Example 1
As shown in fig. 3, the distributed workflow specifically includes: the method comprises the steps of developing by taking a main branch develop branch as a core, creating a development branch on the develop branch, submitting codes to the development branch by developers, obtaining all codes before submitting the codes, ensuring that merge requests submitted after the codes are successfully compiled can pass, finally merging the finished codes into the development branch, and merging the development branch into the develop branch. When a milestone is developed, the milestone status is preserved by creating a Tag. The branches can be frequently created and switched to be isolated from the main code, so that the main code is not polluted due to insufficient perfection in the development process
The Gitlab is a git warehouse based on the web, the project on the Gitlab and the local git version library can be connected through HTTPS or SSH, the url of the warehouse can be set on the Gitlab, the remote project can be added into the remote warehouse of the local version library through the url, and therefore the local code can be pushed to the remote end through the local git server.
As shown in fig. 1 and fig. 2, the present embodiment provides a code management and control method based on a distributed version control system, which includes the following steps:
s1, when a new task is iterated, building a feature branch from the develop branch based on a distributed version control system Git, and creating a user branch from the feature branch;
wherein, newly-built a feature branch specifically is: establishing a feature branch through a git command and pushing the feature branch to a remote end locally or directly establishing the feature branch on a branch management interface of the Gitlab, and locally acquiring the feature branch from the remote end;
s2, code submission: cloning the project source code to the local, and creating a local user branch; after the development is completed, submitting a development file and pushing the development file to a remote user branch, submitting a branch combination request MR in Gitlab and designating an examination terminal;
the process that the Gitlab submits the branch combination request MR and designates the review terminal specifically comprises the following steps: opening a remote warehouse, creating a branch merging request MR, selecting a branch needing to create the branch merging request MR and a branch needing to be merged, and designating an examination terminal;
s3, code examination: the examination terminal evaluates the submitted codes and puts forward an evaluation suggestion, if the code examination is passed, the codes are merged into a feature branch, and if the codes are not passed, the branch merging request MR is closed; the developer optimizes or modifies the codes according to the review opinions and submits the development files again until the review is passed;
s4, version tracking: marking a mark on the feature branch after the iterative development is finished, marking a version number, and pushing the label to a far end;
s5, merging the feature branch into the develop branch.
And generating a unique version number commit id by adopting an SHA-1 algorithm every time the development file is submitted. The SHA-1 algorithm is a digital signature encryption algorithm and one of Hash algorithms. The operation process of the algorithm is specifically as follows: firstly, filling information according to the size of a file (binary system), then explaining the filled data by using a specific rule, grouping the information, dividing each 64 bytes into one group into n groups, circularly performing core operation for n times, and obtaining the SHA1 value after the last group of calculation is finished.
The distributed version control system Git adopts a key value pair database, inserts any content into the database, returns a hash key for retrieving the value, and then stores the content in each code version in the database. Each development branch is associated with a tree object, the tree object stores all file names under the current development branch, corresponding Key values and references of other tree objects, and after the function development is completed, development files are added to a cache region. Each time the file is submitted is a snapshot of the current version, the snapshot comprises a top-level tree object, the image what was submitted last time, a user name of the submitter and a mailbox.
The electronic device of the present invention includes a Central Processing Unit (CPU) that can perform various appropriate actions and processes according to computer program instructions stored in a Read Only Memory (ROM) or computer program instructions loaded from a storage unit into a Random Access Memory (RAM). In the RAM, various programs and data required for the operation of the device can also be stored. The CPU, ROM, and RAM are connected to each other via a bus. An input/output (I/O) interface is also connected to the bus.
A plurality of components in the device are connected to the I/O interface, including: an input unit such as a keyboard, a mouse, or the like; an output unit such as various types of displays, speakers, and the like; storage units such as magnetic disks, optical disks, and the like; and a communication unit such as a network card, modem, wireless communication transceiver, etc. The communication unit allows the device to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The processing unit performs the various methods and processes described above, such as methods S1-S5. For example, in some embodiments, the methods S1-S5 may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device via ROM and/or the communication unit. When the computer program is loaded into RAM and executed by the CPU, one or more of the steps of methods S1-S5 described above may be performed. Alternatively, in other embodiments, the CPU may be configured to perform methods S1-S5 in any other suitable manner (e.g., by way of firmware).
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a load programmable logic device (CPLD), and the like.
Program code for implementing the methods of the present invention may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Example 2
The embodiment provides a code management and control method based on a distributed version control system, which comprises the following steps:
(1) the project is cloned locally.
git clone entry address
(2) And acquiring the remote latest code.
git pull--rebase
(3) The primary branch is switched.
git co feature/P2104
(4) And acquiring the latest code of the remote branch.
git pull--rebase
(5) A local development branch is created.
git co-b user/P2104
(6) And submitting the file.
git commit-am"content"
(7) Push to remote development branch (each push needs to ensure local warehouse is up-to-date, avoiding conflicts).
git fetch
git rebase origin/feature/P2104
git push origin user/P2104
(8) Submitting merge request at Gitlab, opening the warehouse, clicking the merge request at the left side, clicking the new merge request to create an MR, selecting a branch of the MR to be created, determining the branch needing to be merged, and designating an examination terminal.
(9) And the review terminal reviews the code and proposes an opinion, if the code review is passed, the code merge is put into a feature branch, and if the code review is not passed, the merge request is closed.
(10) The developer optimizes the code or modifies the bug against the review opinions.
(11) And submitting the file again until the audit is passed.
(12) Marking the main branch after the iterative development is finished, tracking the version number and pushing the label to the far end.
(13) The feature branch is merged into the develop branch.
(14) When a new task is iterated, a new development main branch is created from the develop branch, the development branch of a developer is created from the main branch, and the processes are repeated.
The other settings were the same as in example 1.
While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (10)
1. A code management and control method based on a distributed version control system is characterized by comprising the following steps:
s1, when a new task is iterated, building a feature branch from the develop branch based on a distributed version control system Git, and creating a user branch from the feature branch;
s2, code submission: cloning the project source code to the local, and creating a local user branch; after the development is completed, submitting a development file and pushing the development file to a remote user branch, submitting a branch combination request MR in Gitlab and designating an examination terminal;
s3, code examination: the examination terminal evaluates the submitted codes and puts forward an evaluation suggestion, if the code examination is passed, the codes are merged into a feature branch, and if the codes are not passed, the branch merging request MR is closed; the developer optimizes or modifies the codes according to the review opinions and submits the development files again until the reviews are passed;
s4, version tracking: marking a mark on the feature branch after the iterative development is finished, marking a version number, and pushing the label to a far end;
s5, merging the feature branch into the develop branch.
2. The code management and control method based on the distributed version control system according to claim 1, wherein a feature branch is newly established in step S1, and specifically:
and (3) locally establishing a feature branch through a git command and then pushing the feature branch to a remote end or directly establishing a feature branch on a branch management interface of the Gitlab, and locally obtaining the feature branch from the remote end.
3. The code management and control method based on the distributed version control system according to claim 1, wherein in step S2, a branch merge request MR is submitted and an audit terminal is designated at Gitlab, and the specific process is as follows:
opening a remote warehouse, creating a branch merging request MR, selecting the branch needing to create the branch merging request MR and the branch needing to be merged, and designating an examination terminal.
4. The code management and control method based on the distributed version control system according to claim 1, wherein a unique version number commit id is generated each time the development file is submitted.
5. The code management and control method based on the distributed version control system according to claim 4, wherein the version number commit id is generated by using SHA-1 algorithm.
6. The code management and control method based on the distributed version control system according to claim 1, wherein the distributed version control system Git adopts a key-value pair database, and when any content is inserted into the database, a hash key for retrieving the value is returned; the content in each code version is stored in the database.
7. The code management and control method based on the distributed version control system according to claim 6, wherein each development branch is associated with a tree object, the tree object stores all file names under the current development branch and references of corresponding Key values and other tree objects, and after the development is completed, the development file is added to the cache region.
8. The code management and control method based on the distributed version control system according to claim 1, wherein each time a file is submitted is a snapshot of a current version, the snapshot includes a top-level tree object, a last submitted object, a what user name and a mailbox.
9. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program, wherein the processor, when executing the program, implements the method of any of claims 1-8.
10. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210104331.4A CN114528008A (en) | 2022-01-28 | 2022-01-28 | Code control method, device and medium based on distributed version control system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210104331.4A CN114528008A (en) | 2022-01-28 | 2022-01-28 | Code control method, device and medium based on distributed version control system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114528008A true CN114528008A (en) | 2022-05-24 |
Family
ID=81623192
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210104331.4A Pending CN114528008A (en) | 2022-01-28 | 2022-01-28 | Code control method, device and medium based on distributed version control system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114528008A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115586919A (en) * | 2022-10-13 | 2023-01-10 | 上海雷昶科技有限公司 | Code management method and device based on git |
CN115629746A (en) * | 2022-12-22 | 2023-01-20 | 西安葡萄城软件有限公司 | Method and system for multi-person collaborative development of low-code platform |
CN116302082A (en) * | 2023-05-24 | 2023-06-23 | 南京砺算科技有限公司 | Version control automatic base changing method, device, equipment and medium |
CN116955719A (en) * | 2023-09-20 | 2023-10-27 | 布谷云软件技术(南京)有限公司 | Code management method and system for digital storage of chained network structure |
CN117130622A (en) * | 2023-10-26 | 2023-11-28 | 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) | Distributed online code compiling and running method and system |
-
2022
- 2022-01-28 CN CN202210104331.4A patent/CN114528008A/en active Pending
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115586919A (en) * | 2022-10-13 | 2023-01-10 | 上海雷昶科技有限公司 | Code management method and device based on git |
CN115629746A (en) * | 2022-12-22 | 2023-01-20 | 西安葡萄城软件有限公司 | Method and system for multi-person collaborative development of low-code platform |
CN115629746B (en) * | 2022-12-22 | 2023-03-17 | 西安葡萄城软件有限公司 | Method and system for multi-person collaborative development of low-code platform |
CN116302082A (en) * | 2023-05-24 | 2023-06-23 | 南京砺算科技有限公司 | Version control automatic base changing method, device, equipment and medium |
CN116955719A (en) * | 2023-09-20 | 2023-10-27 | 布谷云软件技术(南京)有限公司 | Code management method and system for digital storage of chained network structure |
CN116955719B (en) * | 2023-09-20 | 2023-12-05 | 布谷云软件技术(南京)有限公司 | Code management method and system for digital storage of chained network structure |
CN117130622A (en) * | 2023-10-26 | 2023-11-28 | 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) | Distributed online code compiling and running method and system |
CN117130622B (en) * | 2023-10-26 | 2024-01-12 | 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) | Distributed online code compiling and running method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114528008A (en) | Code control method, device and medium based on distributed version control system | |
US10621211B2 (en) | Language tag management on international data storage | |
US20230161746A1 (en) | Data pipeline branching | |
US10705832B2 (en) | Efficient storage and analysis of source code modification history data | |
US11630650B2 (en) | Systems and methods for creating enterprise software | |
CN110865806B (en) | Code processing method, device, server and storage medium | |
US9442719B2 (en) | Regression alerts | |
CN113590172A (en) | Code file publishing method, device, equipment and storage medium | |
CN112765102A (en) | File system management method and device | |
CN111796855A (en) | Incremental version updating method and device, storage medium and computer equipment | |
US9396239B2 (en) | Compiling method, storage medium and compiling apparatus | |
Tan et al. | Detecting outdated code element references in software repository documentation | |
US11392371B2 (en) | Identification of a partial code to be refactored within a source code | |
WO2017072872A1 (en) | Business program generation assistance system and business program generation assistance method | |
CN110728584B (en) | Information processing method and device, readable storage medium and electronic equipment | |
US11829230B2 (en) | Globally unique error codes for knowledge document indexing in software systems | |
US11651852B2 (en) | Methods for surgical guideline indicator mapping to facilitate automated medical bill adjudication and devices thereof | |
Silva et al. | Lm2f: a life-cycle model maintenance framework for co-evolving enterprise architecture meta-models and models | |
US20230252107A1 (en) | Management device, management method, and storage medium | |
EP4109287A1 (en) | A collaborative system and method for multi-user data management | |
CN114169296A (en) | Document processing method and device, electronic equipment and readable storage medium | |
US9747327B2 (en) | Managing content item syndication by maintaining referential integrity between remote or isolated systems | |
CN116226066A (en) | Low code platform code synchronization method and device, electronic equipment and storage medium | |
CN114064474A (en) | Test method, test device, electronic equipment and computer readable storage medium | |
CN112035455A (en) | Metadata processing method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |