#75 Added script to count lines in remote repository #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #75
Added script that count lines in remote repository
OUTPUT
![image](https://private-user-images.githubusercontent.com/143310797/313452604-225c6875-cf34-44b4-a4ad-05e7f8e6c59c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MTg2ODgsIm5iZiI6MTczOTkxODM4OCwicGF0aCI6Ii8xNDMzMTA3OTcvMzEzNDUyNjA0LTIyNWM2ODc1LWNmMzQtNDRiNC1hNGFkLTA1ZTdmOGU2YzU5Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOFQyMjM5NDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hNDk2ODFmZWE3N2JiMWRlOGJmMWZhYTY3NzQ0ODgxODQ4OGJhMGRjMzE0ODJlNTA4MGYwNTkwM2EyNjI0YjRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.sE3F8-txxGPoJezUphNB4vBymArK1-ynqWjcl8EVD_s)
Command Used
bash gitlines <repo_url>
Command Used
![image](https://private-user-images.githubusercontent.com/143310797/313452637-8bb58b87-f9ec-43a2-a0b2-572d6928c417.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MTg2ODgsIm5iZiI6MTczOTkxODM4OCwicGF0aCI6Ii8xNDMzMTA3OTcvMzEzNDUyNjM3LThiYjU4Yjg3LWY5ZWMtNDNhMi1hMGIyLTU3MmQ2OTI4YzQxNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOFQyMjM5NDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03Yzg3ZTc2N2M2NmU3NjQ1MzIyNWNiMDc2YmUyODlkMzQyZWM3ODE2NGE3M2FlYWU5NjA5ZTRiMzZiYmUxYzQ3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.w7yGLq5gxmNzuBrlQU0ZePedfJyK9g30kLzqLtdXe7A)
bash gitlines
EXPLANATION OF CODE
if [ "$#" -eq 0 ]; then
Checks if no argument is passed then asks user to enter the repository name as argument
repo_url=$1
Stores the URL passed into the a variable named
repo_url
temporary_directory=$(mktemp -d)
Creates a temporary directory and stores it in the variable named
temporary_directory
git clone "$repo_url" "$temporary_directory"
Clones the given repository into the local system inside the temporary directory we created
cd "$temporary_directory" || exit
Changes the present working directory into temporary directory
cloc $temporary_directory
This command allows user to count no. of lines in the directory and displays them into the terminal according to the programming language
rm -rf "$temporary_directory"
Removes the directory to prevent the storage from getting full.
rm -rf
is used to forcefully remove the files and folders.