Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 5

Difference in counting the number of rules from GIT

Solved! Go to Solution.

I'm doing Automation to count the total number of rules from the GIT by using the GIT Bash Regular Expression.

  1. Firstly I connected to the GIT Project remotely.
  2. Used the below expression ( git log --numstat |egrep ".brl$" | awk '{for(i=3; i<=NF; ++i) printf "%s ", $i; print ""}' | sort -u | wc -l ) to find the count of rules (extension ending with ".dslr")
  3. But I'm getting the difference in count, e.g., if some rules are in expired folder, it shows those rules in expired folder and other folder as well as shown the highlighted rule as belowCapture.JPG
  4. But when I manually check into the particular folder, 40078 rule is present only in expired folder.
  5. Can anyone help me why this issue is occurring, Is git store some cache or something?
4 Replies
Community Manager
Message 2 of 5

Re: Difference in counting the number of rules from GIT

This sounds more like you're needing help with debugging your one line bash script than a question about git? Can you give us an example of exactly what is not working that is separate from your bash script? Also, it would be helpful if you had a public repository where you could reproduce the problem that we could take a look at.

 

Let us know!

Copilot Lvl 3
Message 3 of 5

Re: Difference in counting the number of rules from GIT

Hey @lee-dohm ,

 

Actually I'm counting the number of files ending with particular extension (e.g. extension can be .brl or .dslr) in a project. So, currently I'm able to find the count of files from git itself by running that command which I mentioned previuosly.

 

But the problem is there are some files say F1.dslr and F2.dslr in Folder1 and Folder2 respectively.

Previuosly F1.dslr file was in Folder1 but now it is moved to Folder 2.

So when I'm counting the files by that command, it shows the F1.dslr file is in both Folder 1&2.

 

But in actual scenario F1.dslr is availbale only in Folder2.

So, my concern is while counting the files, why it shows the F1.dslr file in both folder?

Solution
Community Manager
Message 4 of 5

Re: Difference in counting the number of rules from GIT

But the problem is there are some files say F1.dslr and F2.dslr in Folder1 and Folder2 respectively.

Previuosly F1.dslr file was in Folder1 but now it is moved to Folder 2.

So when I'm counting the files by that command, it shows the F1.dslr file is in both Folder 1&2.

 

The reason for this is that you started your command with `git log --numstat`. This produces the list of every change that has ever been made to your git repository, including every file that does or ever has existed in your repo. If you only want the files that currently exist in your repository, then you should use the `ls` command just like you would with any other directory. Or if you really only want to see the files that git is tracking, you can use the `git ls-files` command.

 

I hope that helps!

Copilot Lvl 3
Message 5 of 5

Re: Difference in counting the number of rules from GIT

Thank you soo much @lee-dohm . It's working now :-)

Thanks a lott.