GithubHelp home page GithubHelp logo

Comments (9)

rtfpessoa avatar rtfpessoa commented on May 26, 2024

@blackdrago diff2html shows new files like this https://diff2html.xyz/demo?diff=https://github.com/rtfpessoa/diff2html-cli/commit/184abc28ee5b47b51169e8981a5225aeff341ec2#d2h-109595

Can you post the unified diff output here?

from diff2html-cli.

blackdrago avatar blackdrago commented on May 26, 2024

This unified diff output is from the following command:
diff --exclude=.svn -ru /home/vagrant/projects/svn/project-name /var/www/html/sandbox/vendor/vendor-name/project-name > diffOut.txt

I've attached diffOut.txt and a screenshot of the diff2html file, which shows 6 changed files (but no new files). Let me know if you need anything else.

[removed attachments]

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

diff2html only finds new files because git diff provides extra information. Since you are using diff it cannot know if the file is new in the same way.

Maybe it can be done by checking if all the lines are new or deleted.

Could be a nice improvement to do. If you are interested a PR would be nice.

We could perform the check here https://github.com/rtfpessoa/diff2html/blob/master/src/diff-parser.js#L64

from diff2html-cli.

blackdrago avatar blackdrago commented on May 26, 2024

Definitely interested. Could you give me a file with sample output from a git diff with modified as well as new / removed files? That would show me what diff2html expects and give me a comparison to start with.

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

A new file git diff would look like this:

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..2c12dfc
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,62 @@
+## How to contribute to diff2html-cli
+
+### Main rules
+
+* Before you open a ticket or send a pull request, [search](https://github.com/rtfpessoa/diff2html-cli/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.

But in your case I think the best way would be just to check if all the lines in the file are new or remove when adding the file to the list after parsing it.

from diff2html-cli.

blackdrago avatar blackdrago commented on May 26, 2024

I found that no code update is necessary. I discovered that diff2html will report new files, you need only pass --new-file to diff:

I was running:
diff --exclude=.svn -ru /localpath /svpath | diff2html -F /var/www/html/diff-out.html -i stdin

"New File" flag:
diff --exclude=.svn --new-file -ru /localpath /svpath | diff2html -F /var/www/html/diff-out.html -i stdin

New and deleted files now appear in the diff2html! :) No code changes necessary. Sorry for raising a non-issue...

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

Ok. Nice no problem.

Still I might pick this when I get some time since it is nice if I can detect this files even without the extra info.

from diff2html-cli.

pbu88 avatar pbu88 commented on May 26, 2024

Just a small note, checking if all the lines are added or deleted might be a legit case of a non-new/deleted file. Say you decide to delete all the lines in a file to start new (or because is part of some process). Same for additions. Is unlikely, but people use git in very different ways.

Finding the right command I think is the best approach. Is not diff2html responsibility to try to figure out what you are trying to do in my opinion.

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

@pbu88 good point.

from diff2html-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.