kiegroup / git-backporting

Git backporting is a CLI tool to execute pull request backporting.
MIT License
15 stars 8 forks source link

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

Closed earl-warren closed 6 months ago

earl-warren commented 6 months ago

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.

github-actions[bot] commented 6 months ago

Coverage report

St.:grey_question:
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 5f12c50c451e799fb6300483c377f0e741958500

earl-warren commented 6 months ago

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 commented 6 months ago

added tests

lampajr commented 6 months ago

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 :rocket:

earl-warren commented 6 months ago

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 commented 6 months ago
* 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

earl-warren commented 6 months ago

Spurious hunks removed at https://github.com/kiegroup/git-backporting/compare/391771b92479930af07bc05dd80e99e4618a1c70..5f12c50c451e799fb6300483c377f0e741958500

earl-warren commented 6 months ago

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 :pray:

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