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.
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"
Related
In TFS 2012 (TFVC), how might I rollback a renamed file to the original filename and contents--without having to manually rename the file (?)
Trying to see if possible just using TFS rollback functionality (e.g., tf rollback), not a combination of tf commands or scripted solution.
SITUATION
Four steps: 1) Add a file; 2) Check it in; 3) Rename the file and edit the contents; and 4) Check it in:
Changeset: 2
Items:
rename, edit $/b.txt
Changeset: 2
Items:
delete, source rename $/a.txt
Changeset: 1
Items:
add $/a.txt
I want to rollback to Changeset 1 (a.txt).
WHAT I'VE TRIED
Source Control Explorer Rollback:
In Microsoft Visual Studio 2017 Professional's Source Control Explorer: right-click b.txt > Rollback... > Rollback to a specific version. Specify Changeset 1, then select button Rollback.
This produces the following pending change:
Items:
delete, rollback $/b.txt
Additionally, a warning appears in Output window:
TF203066: The rename from $/a.txt to $/b.txt could not be rolled back
because you did not provide the source name. To roll back the rename,
undo any pending changes to $/b.txt, and then repeat the operation,
but this time include both the source name ($/a.txt) the target name
($/b.txt).
Note: "Rollback to a specific version" doesn't seem to have fields for source and target names.
This seems to indicate rollback doesn't support this scenario (?)
tf.exe Rollback:
Command tf rollback also doesn't seem to have parameters for source and target names:
tf rollback /toversion:VersionSpec ItemSpec [/recursive]
[/lock:none|checkin|checkout] [/version:versionspec]
[/keepmergehistory] [/login:username,[password]] [/noprompt]
When I run the following command, I get the same results as in Visual Studio:
C:\test>tf vc rollback /toversion:C1 "$/b.txt"
delete, rollback:
$/b.txt;C2~C2 -> $/b.txt;C2
as well as the same warning as before:
TF203066: The rename from $/a.txt to
$/b.txt could not be rolled back because you did not provide the
source name. To roll back the rename, undo any pending changes to
$/b.txt, and then repeat the operation, but this time include both the
source name ($/a.txt) the target name ($/b.txt). C:\test>
Note: tf rename has parameters olditem and newitem, which seems to imply warning TF203066 comes from an incomplete call to tf rename.
This seems to imply manual intervention will always be required to rename the file (?)
SOFTWARE VERSIONS
Microsoft Team Foundation Server 2012 CU4 v11.0.61030.0 (TFVC)
Microsoft Visual Studio 2017 Professional 15.9.13
LINKS
Rollback Command (Team Foundation Version Control)
Rename Command (Team Foundation Version Control)
I have setup Jenkins to run pylint on all python source files and all the log files are generated (apparently correctly) into a sub-directory as follows:
Source\pylint_logs\pylint1.log, pylint2.log, ..., pylint75.log
I have included a --msg-template definition based on the instructions on my Jenkins Configure page: Post-build Actions->Record compiler warnings and static analysis results->Static Analysis Tools. The template is shown as:
msg-template={path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})
An example of one of the log files being generated by Jenkins/pylint is as follows:
************* Module FigureView
myapp\Views\FigureView.py:1: [C0103, ] Module name "FigureView" doesn't conform to snake_case naming style (invalid-name)
myapp\Views\FigureView.py:30: [C0103, FigureView.__init__] Attribute name "ax" doesn't conform to snake_case naming style (invalid-name)
------------------------------------------------------------------
Your code has been rated at 8.57/10 (previous run: 8.57/10, +0.00)
For the PyLint Report File Pattern, I have: Source/pylint_logs/pylint*.log
It appears that PyLint Warnings is parsing the files because the console output looks like this:
[PyLint] Searching for all files in 'D:\Jenkins\workspace\PROJECT' that match the pattern 'Source/pylint_logs/pylint*.log'
[PyLint] -> found 75 files
[PyLint] Successfully parsed file D:\Jenkins\workspace\PROJECT\Source\pylint_logs\pylint1.log
[PyLint] -> found 0 issues (skipped 0 duplicates)
[PyLint] Successfully parsed file D:\Jenkins\workspace\PROJECT\Source\pylint_logs\pylint10.log
[PyLint] -> found 0 issues (skipped 0 duplicates)
This repeats for all 75 files, even though there are plenty of issues in the log files.
What is odd, is that when I was first prototyping the use of Jenkins on this project, I set it up to just run pylint on a single file. I ran across another StackOverflow post that showed a msg-template that allowed me to get it working (unable to get pylint output to populate the violations graph). I even got the graph to show up for the PyLint Warnings Trend. I used the following definition per the post:
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
Note that this format is slightly different from the one recommended by my Jenkins page (shown earlier). Even though this worked for a single file, neither template now seems to work for multiple files, or else there is something other than the template causing the problem. My graph has flat-lined, and I always get 0 issues reported.
I have had trouble finding useful documentation on the Jenkins PyLint Warnings tool. Does anyone have any ideas or pointers to documentation I can research further? Thanks much!
Ensure pass output-format parameter in pylint command. Example:
pylint --exit-zero --output-format=parseable module1 module2 > pylint.report
you have to set the Pylint's option --message-template in .pylintrc as
msg-template={path}: {line}: [{msg_id} ({symbol}), {obj}] {msg}
output-format=text
NUnit.Extension.VSProjectLoader.3.7.0
I try to get a build chain to work with Jenkins Blue Ocean where the sources are in GitHub and additional dependencies are in nuget.
When I restore packages I get the error after the specific package NUnit.Extension.VSProjectLoader.3.7.0:
Errors in packages.config projects
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
On the agent machine the path is very short: C:\guinode\ on top of that additional length is added making the packages folder the following size:
MyGitProject is replacing my actual project name, the length is equal.
C:\guinode\workspace\MyGitProject_master-CFRRXMXQEUULVB4YKQOFGB65CQNC4U5VJKTARN2A6TSBK5PBATBA\packages
Checking the package on the agent machine shows that NUnit.Extension.VSProjectLoader.3.7.0 was loaded completely.
Checking a local installation and replacing the first path of the package I can find two files that are 260 characters or longer.
They belong to an internal project, so I have a chance of influencing that.
None of the directories are 248 characters or more.
So the immediate solution for me is to redeploy the internal reference package.
My question for future reference is if I can do something to the packages location or something to workspace\MyGitProject_master-CFRRXMXQEUULVB4YKQOFGB65CQNC4U5VJKTARN2A6TSBK5PBATBA so that I save some characters per default.
According to the microsoft documentation it can be possible to modify the 260 length rule.
If you prefix your file with '\\?\' eg: '\\?\C:\guinode\workspace...' then long path will be in use ( a little bit more than 32000 char). I hope settings JENKINS_HOME to this kind of path make all process use that (I'm not sure)
On recent Windows version (10.1607, 2016?) there is an option in the registry to enable long path. Set 1 to the following key: HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled (Type: REG_DWORD) and restart the process.
Multiple test cases have been written to test a new Chocolatey function using Pester. How do check whether all branches have been covered?
The current version of Pester (3.0) does support code coverage.
Simply use
Invoke-Pester -CodeCoverage *.ps1
to get a full rapport of code coverage (coverage %) and a summary of all the code lines (branches) not executed during testing:
Tests completed in 10.11s
Passed: 66 Failed: 0 Skipped: 0 Pending: 0
Code coverage report:
Covered 99,20 % of 501 analyzed commands in 22 files.
Missed commands:
File Function Line Command
---- -------- ---- -------
Set-ProgressColor.ps1 Set-ProgressColor 19 Write-Verbose "Progress colors are only supported on the PowerShell com...
UPDATE 2:
Thanks to oɔɯǝɹ for pointing out that Pester has now released a version of Pester that supporting code coverage.
UPDATE 1:
As of Pester Version 3.0, it is now possible to get code coverage information, using:
Invoke-Pester -CodeCoverage <path to file>
This is documented in the project wiki page:
https://github.com/pester/Pester/wiki/Code-Coverage
NOTE: In order to use this, you will require PowerShell version 3.0
ORIGINAL ANSWER:
To the best of my knowledge, Pester doesn't currently support code coverage analysis, but it is something that is being worked on.
There is an open issue for this feature here:
https://github.com/pester/Pester/issues/53
You can see it being worked on here:
http://davewyatt.wordpress.com/2014/06/29/code-coverage-analysis-for-pester-feedback-request/
And there is a screenshot of it working here:
https://twitter.com/nohwnd/status/485093995929157632
So basically, hold tight, and there will hopefully be something soon.
In terms of the actual Chocolatey code base, there is quite a good convention being used, namely that for each *.ps1 file, there "should" be a corresponding ".Tests.ps1 file. If this second file doesn't exist, then there are no unit tests for that function.
Often I'd like to use a previous commit comment (and edit e.g. just one word) for check-in.
I'm used to eclipse, where this feature works quite well.
Is it also available for TFS? I didn't find it yet (despite quick Web search), am I blind?
(I'm currently using TFS 2010 with VisualStudio 2010)
Best regards, Mayoares
I don't think there is anything in VS to help here (except cut and paste via change history).
However a little PowerShell with PSCX (PowerShell community Extensions) and the TFS PowerToys PowerShell snapin will do this, with the current folder set to the solution root:
(Get-TfsItemHistory . -recurse -stop 1).Comment | Set-Clipboard
will put the comment in the clipboard. Using the NuGet powershell session in TFS, this could likely be automated completely (left as exercise).
Not to take away from #Richard for providing the crux to the solution--I have already upvoted his answer--but there is just a bit more to say here.
The OP was just slightly ambiguous: the title leaned toward the capability of selecting some recent commit message while the body was more suggesting to retrieve the most recent commit message. Richard addressed the latter perfectly, but I think it is worth commenting on the former as well.
Consider this function, which uses the same Get-TfsItemHistory from TFS 2013 Power Tools that Richard mentioned:
function Get-TfsComment([string]$pattern = ".*", [string]$Path = ".")
{
Get-TfsItemHistory $Path -Recurse | ? { $_.Comment -match $pattern }
}
With that in place try:
# Get all comments
Get-TfsComment
# Get 10 latest comments
Get-TfsComment | Select -First 10
# Get all comments containing "bug" and "fix"
Get-TfsComment "bug.*fix"
# Get all comments in your tests folder containing "support"
Get-TfsComment -path .\tests -pattern support
The output of this function produces a collection of Microsoft.TeamFoundation.VersionControl.Client.Changeset objects; the list of default properties it displays are typically all you need:
Changes Owner CreationDa Comment
etId te
------- ----- ---------- -------
1187 MYDOMAIN\fred 3/13/2014 Bug fixes for xyz...
1118 MYDOMAIN\wilma 3/7/2014 New features 139 and 448
1076 MYDOMAIN\barney 2/28/2014 Who remembers this...?
. . .
(Note that if you pipe the output to FormatTable -AutoSize that will take care of the poorly optimized line-wrap in the column headers.)