Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate html diff output (for GitLab) #91

Open
sergeyshevch opened this issue Jan 7, 2025 · 6 comments
Open

Generate html diff output (for GitLab) #91

sergeyshevch opened this issue Jan 7, 2025 · 6 comments
Labels
feature-request Feature Request

Comments

@sergeyshevch
Copy link

Hello! I'm looking to expose diff output into gitlab, and for now it's not support .md files to expose on pages.

Maybe it's possible to add .html output with generated styles. Later we can also improve diff readability as well

@dag-andersen
Copy link
Owner

Hi @sergeyshevch
How do you want the html output to look?
Here you can see how the markdown is generated [link]. As you can see it is very basic. We can easily add a another format that works better for GitLab :)

@sergeyshevch
Copy link
Author

sergeyshevch commented Jan 7, 2025

Maybe something like: https://diff2html.xyz. I guess rust also has some solution for it

For not it's slightly hard to send output to comment in gitlab but it already support exposing artifacts on gitlab pages, but it doesn't support markdown for now
https://archives.docs.gitlab.com/16.8/ee/ci/jobs/job_artifacts.html#browse-the-contents-of-the-artifacts-archive

Regarding current diff, maybe it's good idea to place each file in it's own spoiler. It will help reading of large diffs

@sergeyshevch
Copy link
Author

sergeyshevch commented Jan 7, 2025

Maybe I can handle it on my side later then, with something like https://github.com/pycontribs/ansi2html or https://github.com/Wilfred/difftastic/?tab=readme-ov-file

Then it can be good to have just plain git diff as an output and leave postprocessing to end user

@dag-andersen dag-andersen added the feature-request Feature Request label Jan 7, 2025
@dag-andersen
Copy link
Owner

Hi @sergeyshevch

What did you end up doing? :) Would you be open to sharing the script you used to get it working with GitLab? 🚀

Then it can be good to have just plain git diff as an output and leave postprocessing to end user

If you want to get the raw output of git diff you can just run after the tool finishes:

git --no-pager diff --no-prefix -U5 --no-index ./output/base ./output/target

@sergeyshevch
Copy link
Author

@dag-andersen I found correct way to post it to Gitlab

curl -X POST -g -H "PRIVATE-TOKEN: ${ARGO_GITLAB_TOKEN}" \
        --data-urlencode "body@output/diff.md" \
        "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/merge_requests/${CI_MERGE_REQUEST_IID}/discussions" > /dev/null

Also I guess this comemment can be really improved if we split diff spoiler per application

Like

app1
diff
app2
diff
app3
diff

@dag-andersen
Copy link
Owner

@sergeyshevch
Amazing!

I haven't worked with GitLab in a long time. Would you mind sharing the full pipeline you're using? If so, I can add it to the docs so others can see how to use the tool with GitLab

Alternatively, if you'd like to contribute, you can add a page similar to this one: GitHub Actions Workflow.

@dag-andersen dag-andersen changed the title Generate html diff output Generate html diff output (for GitLab) Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Feature Request
Projects
None yet
Development

No branches or pull requests

2 participants