jenkinsci / last-changes-plugin

https://plugins.jenkins.io/last-changes
https://plugins.jenkins.io/last-changes/
31 stars 31 forks source link

compare modifyed workspace with Head SVN revison #60

Open Vintic opened 5 years ago

Vintic commented 5 years ago

Hi. After build, I need to check what changes build made comparing with last revision. As i understood, plugin retrieve revision from workspace and then compare it with specified revision? Or it compare workspace with specified revision, and I use it wrong?

Why I need it. Before I deploy release to production, I need to check if was made some hot fixes directly on production without committing them in SVN. What I think to do. I will download that changes using RSync to Jenkins workspace and check modification with Last Changes Plugin. If all is OK I will deploy release to production.

rmpestano commented 5 years ago

Hi, the plugin needs the source code to be commited to a VCS because It uses source control commands to create the diff like svn diff or git diff. It will read current code revision from the workspace and compare with other revision.

About your use case I think you just need a delivery pipeline which has a stage where you can check the changes before going to next stage that can be the deploy to production.

Vintic commented 5 years ago

ok, but it is possible to compare files from work space with those from head revision like SVN Diff make? For example if, was specified head revision in Specific revision section, to use this code: diff.setSources(SvnTarget.fromURL(new File(lastCommitInfo.getCommitFilePath())), SvnTarget.fromURL(repository.getLocation(), SVNRevision.create(currentRevision)));

rmpestano commented 5 years ago

As far as I know (I may be wrong) the diff is done between two revisions and you don't have a revision until you commit to the repository.

Anyway even if possible I don't plan to add support for such usecase unless the fix is transparent to enduser (e.g no UI change) and minor change is required to the plugin codebase.

Vintic commented 5 years ago

Being in checkout directory and writing in command line " svn diff --revision 26347 " it display local changes that was made.

Vintic commented 5 years ago

Here is implementation with SVNDiffClient: https://wiki.svnkit.com/Diffing%20a%20working%20copy%20against%20a%20repository

rmpestano commented 5 years ago

I see, I still think it is a very "strange" use case to support.

I'd suggest you to fork this plugin and add the feature you need. You can see build and run instructions here.

Vintic commented 5 years ago

Thank you,

I found a solution and made some changes in code: Now when I write in "Specific revision" word: "Base".

Is executing something like: lastChanges = svnLastChanges.changesOf(repository, SVNRevision.WORKING, SVNRevision.BASE);

and some minor changes was added to work properly.

rmpestano commented 5 years ago

Nice, glad you made it working!

Lets keep this issue opened and if more users ask for It we can think in incorporate into master.

Vintic commented 5 years ago

Hi, again)

How I can add file description ( like: modified date ) in the header of file diff div.

Usage: I want to highlight files that was modified on production from last build, by checking file modified date and last success build date.

rmpestano commented 5 years ago

Hi,

the list of changed files is generated by diff2html, you may ask there if there's a way to add info to the list.

You probably know but the UI code of this plugin resides in this jelly file: https://github.com/jenkinsci/last-changes-plugin/blob/50814d8d722c89a159b440ab60cdd145696745c7/src/main/resources/com/github/jenkins/lastchanges/LastChangesBuildAction/index.jelly

SunBlack commented 3 years ago

I agree with @Vintic that it would be nice to be able to compare the working directory with the last commit. This way it would be possible to show changes by clang-format or other code formatting tools for example (and in best case the tool can also set the build failure state if there is a change).