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

feat: add --git-client to explicitly set the type of forge #106

Merged
merged 1 commit into from
Mar 23, 2024

Conversation

earl-warren
Copy link
Contributor

codeberg is running Forgejo and it may not be possible to infer that from the URL alone. The same is true for GitHub Enterprise Server.

Copy link
Contributor

github-actions bot commented Mar 22, 2024

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
91.28% (+0.46% 🔼)
429/470
🟢 Branches
85.86% (+1.67% 🔼)
170/198
🟢 Functions 88.24% 105/119
🟢 Lines
91.23% (+0.48% 🔼)
416/456

Test suite run success

169 tests passing in 16 suites.

Report generated by 🧪jest coverage report action from 5f12c50

@earl-warren
Copy link
Contributor Author

This is probably not how you would like that implemented and I'm ready to make improvements. The original author of the patch may also be willing to improve upon it.

@earl-warren
Copy link
Contributor Author

added tests

@lampajr
Copy link
Member

lampajr commented Mar 23, 2024

Hey @earl-warren , this looks a great idea!

I see you already added some tests, thx a lot!

After a quick check looks good to me, I will deeply check it in a while 🚀

Copy link
Member

@lampajr lampajr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great to me!

Just a couple of missing things:

  • Could you please add the same git-client param in the action.yaml for the GHA
  • If I run npm run build locally I see the following diff:
   "query",
   "search",
-  "hash",
 ];
 
 // Create handlers that pass events from native requests
@@ -6325,7 +6324,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
      redirectUrl.protocol !== "https:" ||
      redirectUrl.host !== currentHost &&
      !isSubdomain(redirectUrl.host, currentHost)) {
-    removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
+    removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
   }
 
   // Evaluate the beforeRedirect callback
diff --git a/dist/gha/index.js b/dist/gha/index.js
index b50c45c..21cc4e7 100755
--- a/dist/gha/index.js
+++ b/dist/gha/index.js
@@ -7621,7 +7621,6 @@ var preservedUrlFields = [
   "protocol",
   "query",
   "search",
-  "hash",
 ];
 
 // Create handlers that pass events from native requests
@@ -8055,7 +8054,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
      redirectUrl.protocol !== "https:" ||
      redirectUrl.host !== currentHost &&
      !isSubdomain(redirectUrl.host, currentHost)) {
-    removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
+    removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
   }

Do you mind to double check this?

@earl-warren
Copy link
Contributor Author

Overall looks great to me!

Just a couple of missing things:

* Could you please add the same `git-client` param in the [`action.yaml`](https://github.com/kiegroup/git-backporting/blob/main/action.yml#L3-L72) for the GHA

* If I run `npm run build` locally I see the following diff:
   "query",
   "search",
-  "hash",
 ];
 
 // Create handlers that pass events from native requests
@@ -6325,7 +6324,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
      redirectUrl.protocol !== "https:" ||
      redirectUrl.host !== currentHost &&
      !isSubdomain(redirectUrl.host, currentHost)) {
-    removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
+    removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
   }
 
   // Evaluate the beforeRedirect callback
diff --git a/dist/gha/index.js b/dist/gha/index.js
index b50c45c..21cc4e7 100755
--- a/dist/gha/index.js
+++ b/dist/gha/index.js
@@ -7621,7 +7621,6 @@ var preservedUrlFields = [
   "protocol",
   "query",
   "search",
-  "hash",
 ];
 
 // Create handlers that pass events from native requests
@@ -8055,7 +8054,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
      redirectUrl.protocol !== "https:" ||
      redirectUrl.host !== currentHost &&
      !isSubdomain(redirectUrl.host, currentHost)) {
-    removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
+    removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
   }

Do you mind to double check this?

I have no clue why it does that in my environment. I'll remove these hunks and figure that out later.

@earl-warren
Copy link
Contributor Author

* Could you please add the same `git-client` param in the [`action.yaml`](https://github.com/kiegroup/git-backporting/blob/main/action.yml#L3-L72) for the GHA

Fixed https://github.com/kiegroup/git-backporting/compare/0f0812afb92578ca7750ba44c2bc8441f60262ae..391771b92479930af07bc05dd80e99e4618a1c70

codeberg is running Forgejo and it may not be possible to infer that
from the URL alone. The same is true for GitHub Enterprise Server.
@earl-warren
Copy link
Contributor Author

@earl-warren
Copy link
Contributor Author

Here is the output of npm run build on my environment. There evidently is a difference in my environment that matters but I don't know how to figure that out. Do you have a suggestion? Not that it matters in the context of this PRs but it would be nice to have clean content the next time around 🙏

earl-warren:~/software/git-backporting$ npm run build

> @kie/git-backporting@4.5.2 build
> npm run clean && npm run compile && npm run package


> @kie/git-backporting@4.5.2 clean
> rm -rf ./build ./dist


> @kie/git-backporting@4.5.2 compile
> tsc -p tsconfig.json && tsc-alias -p tsconfig.json


> @kie/git-backporting@4.5.2 package
> npm run package:cli && npm run package:gha


> @kie/git-backporting@4.5.2 package:cli
> ncc build ./build/src/bin/cli.js -o dist/cli

ncc: Version 0.36.0
ncc: Compiling file index.js into CJS
1105kB  dist/cli/index.js
1105kB  [950ms] - ncc 0.36.0

> @kie/git-backporting@4.5.2 package:gha
> ncc build ./build/src/bin/gha.js -o dist/gha

ncc: Version 0.36.0
ncc: Compiling file index.js into CJS
1095kB  dist/gha/index.js
1095kB  [1009ms] - ncc 0.36.0
earl-warren:~/software/git-backporting$ git diff
diff --git a/dist/cli/index.js b/dist/cli/index.js
index a3f1819..77ad9bf 100755
--- a/dist/cli/index.js
+++ b/dist/cli/index.js
@@ -5891,6 +5891,7 @@ var preservedUrlFields = [
   "protocol",
   "query",
   "search",
+  "hash",
 ];
 
 // Create handlers that pass events from native requests
@@ -6324,7 +6325,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
      redirectUrl.protocol !== "https:" ||
      redirectUrl.host !== currentHost &&
      !isSubdomain(redirectUrl.host, currentHost)) {
-    removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
+    removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
   }
 
   // Evaluate the beforeRedirect callback
diff --git a/dist/gha/index.js b/dist/gha/index.js
index 21cc4e7..b50c45c 100755
--- a/dist/gha/index.js
+++ b/dist/gha/index.js
@@ -7621,6 +7621,7 @@ var preservedUrlFields = [
   "protocol",
   "query",
   "search",
+  "hash",
 ];
 
 // Create handlers that pass events from native requests
@@ -8054,7 +8055,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
      redirectUrl.protocol !== "https:" ||
      redirectUrl.host !== currentHost &&
      !isSubdomain(redirectUrl.host, currentHost)) {
-    removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
+    removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
   }
 
   // Evaluate the beforeRedirect callback

Copy link
Member

@lampajr lampajr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great!

Here is the output of npm run build on my environment. There evidently is a difference in my environment that matters but I don't know how to figure that out. Do you have a suggestion? Not that it matters in the context of this PRs but it would be nice to have clean content the next time around 🙏

To be honest I've never faced this weird issue, do you mind to create an issue adding this diff and some additional infos like the system you are using alongside the npm and node version? Then I can try to investigate a bit more if I can find something / or to reproduce.

Anyway as you said this is not blocking this PR and it looks great to me!

Thanks a lot for your contribution @earl-warren ❤️

@lampajr lampajr merged commit 80a0b55 into kiegroup:main Mar 23, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants