Search code examples
jiraperforcegame-developmentswarm

How to find who last changed am file with perforce?


I have an idea but I'm not sure how it can be implemented. I use Jira/Perforce/Swarm, and I want to automatically include the name of the engineer who last changed a file. The name of the engineer should be included to the generated bugs/crashes in Jira.

Here is an example: Tod changed file TestFile.cpp. Tod's work has been merged into master branch. Assertion occurred and a bug in Jira was created with reference to the file.

How can we let the system know that Tod was the engineer who changed this file last?

Thank you in advance.


Solution

  • You can get this information from the p4 changes and/or p4 filelog commands:

    C:\Perforce\test>p4 filelog TestFile.cpp
    //stream/child_stream/TestFile.cpp
    ... #2 change 290 edit on 2022/03/29 by Tod@Samwise-dvcs-1509687817 (text) 'Tod's awesome change'
    ... #1 change 289 add on 2022/03/29 by Samwise@Samwise-dvcs-1509687817 (text) 'added file'
    
    C:\Perforce\test>p4 changes -m1 TestFile.cpp
    Change 290 on 2022/03/29 by Tod@Samwise-dvcs-1509687817 'Tod's awesome change'
    

    If your automation is able to identify specific lines of code that introduced bugs, you might also find p4 annotate useful for tracing those lines of code to specific Perforce revisions/users:

    C:\Perforce\test>p4 annotate -Tu TestFile.cpp
    //stream/child_stream/TestFile.cpp#2 - edit change 290 (text)
         1:      Samwise 2022/03/29 asdfasdf
         2:          Tod 2022/03/29 "tod"