yor icon indicating copy to clipboard operation
yor copied to clipboard

Warning - Unable to get git blame for file

Open ephos opened this issue 3 years ago • 4 comments

I have tried this in a few different Git repositories I have cloned down and can reproduce it on all. It will add the yor_trace tags but none of the Git tags.

Command Run (from the root of the Git repo):

yor tag -d .\env\

Error:

2021/06/11 12:56:30 [WARNING] Unable to get git blame for file env\aks.tf: failed to get blame for latest commit of file env\aks.tf because of error file not found
2021/06/11 12:56:30 [WARNING] Failed to tag azurerm_kubernetes_cluster.aks with git tags, err: failed to get blame for latest commit of file env\aks.tf because of error failed to get blame for latest commit of file env\aks.tf because of error file not found

Environment information:

  • Yor Version: v0.1.61
  • Git Version: 2.31.0.windows.1
  • Terraform Version: 1.0.0

In all cases I am in a valid Git repository. All of the other Git command work (including git blame). Not sure if I am doing something or running into a bug on this one.

ephos avatar Jun 11 '21 17:06 ephos

Hi @ephos ! I think this issue was handled in #147 . Can you try this again with version >= 0.1.67?

nimrodkor avatar Jun 20 '21 06:06 nimrodkor

Unfortunately the issue still seems to exist.

Command run:

yor tag -d .

Output:

2021/06/21 08:45:45 [WARNING] Unable to get git blame for file main.tf: failed to get blame for latest commit of file main.tf because of error file not found
2021/06/21 08:45:45 [WARNING] Failed to tag azurerm_resource_group.rgp with git tags, err: failed to get blame for latest commit of file main.tf because of error failed to get blame for latest commit of file main.tf because of error file not found
2021/06/21 08:45:45 [WARNING] Unable to get git blame for file main.tf: failed to get blame for latest commit of file main.tf because of error file not found
2021/06/21 08:45:45 [WARNING] Failed to tag azurerm_storage_account.storage with git tags, err: failed to get blame for latest commit of file main.tf because of error failed to get blame for latest commit of file main.tf because of error file not found

  __    __
  \ \  / /
   \ \/ /___  _  ____
    \  /  _ \| |/  __|
    | |  |_| |   /
    |_|\____/|__|v0.1.69
 Yor Findings Summary
 Scanned Resources:       6
 New Resources Traced:    0
 Updated Resources:       0

This is the repo layout \tf-test-repo\sandbox where tf-test-repo is the root of the Git repo and the Terraform files live in an environment specific folder.

        Directory: C:\Users\user\code\git\tf-test-repo\sandbox

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         6/11/2021  12:01 PM                     .terraform
-a---         6/11/2021  12:01 PM           2338   .terraform.lock.hcl
-a---         6/21/2021   8:45 AM           1809   main.tf
-a---         5/28/2021  12:09 PM            459   variables.tf
-a---         5/28/2021  12:09 PM            445   versions.tf

Edit / Quick Update

I just tried with v0.2.0-4825ae8 and had the same results.

ephos avatar Jun 21 '21 12:06 ephos

I see you're running on windows, that might be related as we're using paths and git etc. I'll try to debug this

nimrodkor avatar Jun 22 '21 11:06 nimrodkor

Yes, unfortunately I am stuck on Win 10 for my local dev environment. I haven't yet looked at wiring it up in a build pipeline (using Azure DevOps Repos/Pipelines). In that case I will be able to leverage containers or Linux build agents.

ephos avatar Jun 22 '21 13:06 ephos

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 05 '23 19:02 stale[bot]

The issue still exists in the latest version 0.1.188 when running on Azure DevOps with ubuntu-latest image. Same when running locally on Windows 11. Any idea?

2024/02/09 09:20:06 [WARNING] Unable to get git blame for file /home/vsts/work/1/s/resources.tf: failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Failed to tag azurerm_resource_group.rg with git tags, err: failed to get blame for latest commit of file /home/vsts/work/1/s/resources.tf because of error failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Unable to get git blame for file /home/vsts/work/1/s/resources.tf: failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Failed to tag azurerm_resource_group.rg2 with git tags, err: failed to get blame for latest commit of file /home/vsts/work/1/s/resources.tf because of error failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Unable to get git blame for file /home/vsts/work/1/s/resources.tf: failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Failed to tag azurerm_resource_group.rg3 with git tags, err: failed to get blame for latest commit of file /home/vsts/work/1/s/resources.tf because of error failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Unable to get git blame for file /home/vsts/work/1/s/resources.tf: failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Failed to tag azurerm_network_security_group.nsg with git tags, err: failed to get blame for latest commit of file /home/vsts/work/1/s/resources.tf because of error failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Unable to get git blame for file /home/vsts/work/1/s/resources.tf: failed to get previous commit: object not found
2024/02/09 09:20:06 [WARNING] Failed to tag azurerm_virtual_network.vnet with git tags, err: failed to get blame for latest commit of file /home/vsts/work/1/s/resources.tf because of error failed to get previous commit: object not found
  __    __
  \ \  / /
   \ \/ /___  _  ____
    \  /  _ \| |/  __|
    | |  |_| |   /
    |_|\____/|__|v0.1.188
 Yor Findings Summary
 Scanned Resources:	  5
 New Resources Traced: 	  0
 Updated Resources:	  0

matthiasguentert avatar Feb 09 '24 09:02 matthiasguentert

@matthiasguentert I had this issue as well. The fix for me was making sure that the fetchDepth was set to 0 and making sure to do git checkout $(Build.SourceBranchName) before the yor tag -d command

mmyers299 avatar Feb 12 '24 16:02 mmyers299