Count lines of code in a branch
This article describes how to use a Flow pipeline to count the lines of code in a branch.
Count code lines with a pipeline
You can use the open-source script CLOC to easily count the lines of code in a branch. This helps you measure development activity in a code repository. Using a Flow pipeline makes this process even simpler.
Create a pipeline
-
In your target code repository, click Pipelines to create a pipeline that automates code scanning, builds, and deployments.
-
Click New Pipeline and then select Empty Template·Empty Template.
-
Configure the code source.
In the Edit Pipeline Source panel, select Codeup as the code source, configure the service connection, select a code repository (for example, lifeRestart), and set the default branch to master. Enable the Code source trigger switch and select Code push as the trigger event. Flow will automatically add a webhook to the code source.
-
Select .
Enter the following commands:
npm install -g cloc cloc ./For Node Version, select 14.8.
-
Click Save and Run.
ImportantThe script counts the lines of code in the branch that triggers the pipeline. Run the pipeline on the branch you want to analyze.
In the Run Configuration dialog box, set the Branch to the branch you want to analyze (for example,
master), and then click Run.
View the results
When the pipeline finishes running, you can view the related information in the view.
[User Command] + cloc ./
github.com/AlDanial/cloc v 2.02 T=1.67 s (107.7 files/s, 189032.0 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
JavaScript 131 13845 30402 124598
JSON 11 0 0 94626
TypeScript 3 1017 23157 14815
Qt 23 0 0 12976
HTML 6 26 42 272
Markdown 3 53 0 95
XML 1 0 0 39
Dockerfile 1 7 0 8
YAML 1 0 0 1
-------------------------------------------------------------------------------
SUM: 180 14948 53601 247430
-------------------------------------------------------------------------------
[SUCCESS]