From dbdd7e6f396ab71030f6bf59b4c03f33feea8a8d Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Sat, 13 Jan 2024 12:57:18 +0800 Subject: [PATCH 1/7] check --- src/scm/driver/github/git.rs | 5 ++--- src/scm/driver/gitlab/git.rs | 7 ++++++- src/scm/git.rs | 2 +- tests/scm/driver/github/git.rs | 3 +-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/scm/driver/github/git.rs b/src/scm/driver/github/git.rs index fb9e738..40f98f4 100644 --- a/src/scm/driver/github/git.rs +++ b/src/scm/driver/github/git.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::HashMap; use serde::{Deserialize, Serialize}; +use std::collections::HashMap; -use super::constants::{GITHUB_PATH_BRANCHES, GITHUB_PATH_COMMITS, GITHUB_PATH_TAGS, GITHUB_PATH_GIT_TREES}; +use super::constants::{GITHUB_PATH_BRANCHES, GITHUB_PATH_COMMITS, GITHUB_PATH_GIT_TREES, GITHUB_PATH_TAGS}; use super::utils::convert_list_options; use super::GithubFile; use crate::http::{Client, Endpoint}; @@ -87,7 +87,6 @@ impl GitService for GithubGitService { let res = self.client.get::(&path, Some(options))?; Ok(res.data.map(|v| v.into())) } - } #[derive(Debug, Deserialize, Serialize)] diff --git a/src/scm/driver/gitlab/git.rs b/src/scm/driver/gitlab/git.rs index 45c2f8b..1510dc4 100644 --- a/src/scm/driver/gitlab/git.rs +++ b/src/scm/driver/gitlab/git.rs @@ -71,7 +71,12 @@ impl GitService for GitlabGitService { Ok(res.data.map(|v| v.into())) } - fn git_trees(&self, _repo: &str, _tree_sha: &str, _recursive: Option) -> anyhow::Result> { + fn git_trees( + &self, + _repo: &str, + _tree_sha: &str, + _recursive: Option, + ) -> anyhow::Result> { todo!() } } diff --git a/src/scm/git.rs b/src/scm/git.rs index 6b3322b..6c87d60 100644 --- a/src/scm/git.rs +++ b/src/scm/git.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use serde::Deserialize; use super::client::ListOptions; +use serde::Deserialize; /// Represents a git reference. #[derive(Debug, PartialEq)] diff --git a/tests/scm/driver/github/git.rs b/tests/scm/driver/github/git.rs index fbf86c4..0d04a1d 100644 --- a/tests/scm/driver/github/git.rs +++ b/tests/scm/driver/github/git.rs @@ -15,7 +15,7 @@ use crate::common::mock; use amp_common::scm::client::ListOptions; use amp_common::scm::driver::github::constants::{ - GITHUB_PATH_BRANCHES, GITHUB_PATH_COMMITS, GITHUB_PATH_TAGS, GITHUB_PATH_GIT_TREES, + GITHUB_PATH_BRANCHES, GITHUB_PATH_COMMITS, GITHUB_PATH_GIT_TREES, GITHUB_PATH_TAGS, }; use amp_common::scm::driver::github::git::GithubGitService; use amp_common::scm::git::GitService; @@ -70,5 +70,4 @@ fn test_git_trees() { let service = GithubGitService { client: setup.0 }; let result = service.git_trees(REPO, REFERENCE, Some(true)); assert!(result.is_ok()); - } From 52266ae4075706ad5e57a8c4196e8778da77cadf Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Sat, 13 Jan 2024 13:17:45 +0800 Subject: [PATCH 2/7] check --- src/scm/driver/github/git.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scm/driver/github/git.rs b/src/scm/driver/github/git.rs index 40f98f4..abb47ba 100644 --- a/src/scm/driver/github/git.rs +++ b/src/scm/driver/github/git.rs @@ -85,7 +85,7 @@ impl GitService for GithubGitService { let recursive = recursive.unwrap_or(true); options.insert(String::from("recursive"), recursive.to_string()); let res = self.client.get::(&path, Some(options))?; - Ok(res.data.map(|v| v.into())) + Ok(res.data) } } From dc4d35e249d540f7de7a80acfe589ba3a2f09c54 Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Sat, 13 Jan 2024 14:27:07 +0800 Subject: [PATCH 3/7] Change .Http Formatting --- .../scm/github/git/git-trees-success.http | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/tests/fixtures/scm/github/git/git-trees-success.http b/tests/fixtures/scm/github/git/git-trees-success.http index 0fc5299..dba4592 100644 --- a/tests/fixtures/scm/github/git/git-trees-success.http +++ b/tests/fixtures/scm/github/git/git-trees-success.http @@ -1,30 +1,29 @@ -HTTP/1.1 200 OK -Server: GitHub.com -Date: Fri, 12 Jan 2024 15:29:06 GMT -Content-Type: application/json; charset=utf-8 -Cache-Control: public, max-age=60, s-maxage=60 -Vary: Accept, Accept-Encoding, Accept, X-Requested-With -ETag: W/"122c1cb1624fc0caae5bb8a69852b535c721ce8ecddd2db05374e5d2c699cf61" -Last-Modified: Fri, 12 Jan 2024 05:37:27 GMT -X-GitHub-Media-Type: github.v3; format=json +HTTP/2 200 +server: GitHub.com +date: Thu, 17 Aug 2023 15:51:04 GMT +content-type: application/json; charset=utf-8 +cache-control: public, max-age=60, s-maxage=60 +vary: Accept, Accept-Encoding, Accept, X-Requested-With +etag: W/"52fb8dc836f8b3786bf1ade9f5b536a72bcafc8f89f6f5ddbb18bdcfc2f859e4" +last-modified: Tue, 06 Mar 2012 23:06:50 GMT +x-github-media-type: github.v3; format=json x-github-api-version-selected: 2022-11-28 -Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset -Access-Control-Allow-Origin: * -Strict-Transport-Security: max-age=31536000; includeSubdomains; preload -X-Frame-Options: deny -X-Content-Type-Options: nosniff -X-XSS-Protection: 0 -Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin -Content-Security-Policy: default-src 'none' -Content-Encoding: gzip -X-RateLimit-Limit: 60 -X-RateLimit-Remaining: 55 -X-RateLimit-Reset: 1705073498 -X-RateLimit-Resource: core -X-RateLimit-Used: 5 -Accept-Ranges: bytes -Content-Length: 231 -X-GitHub-Request-Id: E91C:2E0C86:C27F85A:C4AA8BD:65A15AC2 +access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset +access-control-allow-origin: * +strict-transport-security: max-age=31536000; includeSubdomains; preload +x-frame-options: deny +x-content-type-options: nosniff +x-xss-protection: 0 +referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin +content-security-policy: default-src 'none' +x-ratelimit-limit: 60 +x-ratelimit-remaining: 55 +x-ratelimit-reset: 1692289733 +x-ratelimit-resource: core +x-ratelimit-used: 5 +accept-ranges: bytes +content-length: 4685 +x-github-request-id: 4FD7:6061:61E949:66205F:64DE41E8 { "sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", From 63460ba1f7e9d2acc4834ec507251d87120f7487 Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Sat, 13 Jan 2024 15:39:38 +0800 Subject: [PATCH 4/7] Change .Http Formatting --- .../scm/github/git/git-trees-success.http | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/tests/fixtures/scm/github/git/git-trees-success.http b/tests/fixtures/scm/github/git/git-trees-success.http index dba4592..5e0d11a 100644 --- a/tests/fixtures/scm/github/git/git-trees-success.http +++ b/tests/fixtures/scm/github/git/git-trees-success.http @@ -1,29 +1,29 @@ -HTTP/2 200 -server: GitHub.com -date: Thu, 17 Aug 2023 15:51:04 GMT -content-type: application/json; charset=utf-8 -cache-control: public, max-age=60, s-maxage=60 -vary: Accept, Accept-Encoding, Accept, X-Requested-With -etag: W/"52fb8dc836f8b3786bf1ade9f5b536a72bcafc8f89f6f5ddbb18bdcfc2f859e4" -last-modified: Tue, 06 Mar 2012 23:06:50 GMT -x-github-media-type: github.v3; format=json +HTTP/1.1 200 OK +Server: GitHub.com +Date: Sat, 13 Jan 2024 07:37:57 GMT +Content-Type: application/json; charset=utf-8 +Cache-Control: public, max-age=60, s-maxage=60 +Vary: Accept, Accept-Encoding, Accept, X-Requested-With +ETag: W/"122c1cb1624fc0caae5bb8a69852b535c721ce8ecddd2db05374e5d2c699cf61" +Last-Modified: Sat, 13 Jan 2024 04:05:18 GMT +X-GitHub-Media-Type: github.v3; format=json x-github-api-version-selected: 2022-11-28 -access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset -access-control-allow-origin: * -strict-transport-security: max-age=31536000; includeSubdomains; preload -x-frame-options: deny -x-content-type-options: nosniff -x-xss-protection: 0 -referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin -content-security-policy: default-src 'none' -x-ratelimit-limit: 60 -x-ratelimit-remaining: 55 -x-ratelimit-reset: 1692289733 -x-ratelimit-resource: core -x-ratelimit-used: 5 -accept-ranges: bytes -content-length: 4685 -x-github-request-id: 4FD7:6061:61E949:66205F:64DE41E8 +Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset +Access-Control-Allow-Origin: * +Strict-Transport-Security: max-age=31536000; includeSubdomains; preload +X-Frame-Options: deny +X-Content-Type-Options: nosniff +X-XSS-Protection: 0 +Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin +Content-Security-Policy: default-src 'none' +X-RateLimit-Limit: 60 +X-RateLimit-Remaining: 58 +X-RateLimit-Reset: 1705134976 +X-RateLimit-Resource: core +X-RateLimit-Used: 2 +Accept-Ranges: bytes +Content-Length: 479 +X-GitHub-Request-Id: 4642:B1098:D4200:E4058:65A23DD5 { "sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", @@ -40,4 +40,3 @@ x-github-request-id: 4FD7:6061:61E949:66205F:64DE41E8 ], "truncated": false } - From 85d8a970273a63970bc50b170cfe6169da49da53 Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Sat, 13 Jan 2024 16:02:41 +0800 Subject: [PATCH 5/7] Change .Http Formatting --- .../git/{git-trees-success.http => trees-success.http} | 8 ++++---- tests/scm/driver/github/git.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename tests/fixtures/scm/github/git/{git-trees-success.http => trees-success.http} (92%) diff --git a/tests/fixtures/scm/github/git/git-trees-success.http b/tests/fixtures/scm/github/git/trees-success.http similarity index 92% rename from tests/fixtures/scm/github/git/git-trees-success.http rename to tests/fixtures/scm/github/git/trees-success.http index 5e0d11a..06fea6d 100644 --- a/tests/fixtures/scm/github/git/git-trees-success.http +++ b/tests/fixtures/scm/github/git/trees-success.http @@ -1,6 +1,6 @@ HTTP/1.1 200 OK Server: GitHub.com -Date: Sat, 13 Jan 2024 07:37:57 GMT +Date: Sat, 13 Jan 2024 08:01:32 GMT Content-Type: application/json; charset=utf-8 Cache-Control: public, max-age=60, s-maxage=60 Vary: Accept, Accept-Encoding, Accept, X-Requested-With @@ -17,13 +17,13 @@ X-XSS-Protection: 0 Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin Content-Security-Policy: default-src 'none' X-RateLimit-Limit: 60 -X-RateLimit-Remaining: 58 +X-RateLimit-Remaining: 54 X-RateLimit-Reset: 1705134976 X-RateLimit-Resource: core -X-RateLimit-Used: 2 +X-RateLimit-Used: 6 Accept-Ranges: bytes Content-Length: 479 -X-GitHub-Request-Id: 4642:B1098:D4200:E4058:65A23DD5 +X-GitHub-Request-Id: 4759:B1098:F5468:107910:65A2435B { "sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", diff --git a/tests/scm/driver/github/git.rs b/tests/scm/driver/github/git.rs index 0d04a1d..bbcc29f 100644 --- a/tests/scm/driver/github/git.rs +++ b/tests/scm/driver/github/git.rs @@ -66,7 +66,7 @@ fn test_git_trees() { .replace("{repo}", REPO) .replace("{tree_sha}", REFERENCE); - let setup = mock("GET", &path, "scm/github/git/git-trees-success"); + let setup = mock("GET", &path, "scm/github/git/trees-success"); let service = GithubGitService { client: setup.0 }; let result = service.git_trees(REPO, REFERENCE, Some(true)); assert!(result.is_ok()); From dc22498d4ba56df16d912cca540ee939eae14d6b Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Sat, 13 Jan 2024 16:13:00 +0800 Subject: [PATCH 6/7] Update trees-success.http Change .Http Formatting --- tests/fixtures/scm/github/git/trees-success.http | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/fixtures/scm/github/git/trees-success.http b/tests/fixtures/scm/github/git/trees-success.http index 06fea6d..1f98979 100644 --- a/tests/fixtures/scm/github/git/trees-success.http +++ b/tests/fixtures/scm/github/git/trees-success.http @@ -1,6 +1,6 @@ HTTP/1.1 200 OK Server: GitHub.com -Date: Sat, 13 Jan 2024 08:01:32 GMT +Date: Sat, 13 Jan 2024 08:10:26 GMT Content-Type: application/json; charset=utf-8 Cache-Control: public, max-age=60, s-maxage=60 Vary: Accept, Accept-Encoding, Accept, X-Requested-With @@ -17,13 +17,13 @@ X-XSS-Protection: 0 Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin Content-Security-Policy: default-src 'none' X-RateLimit-Limit: 60 -X-RateLimit-Remaining: 54 +X-RateLimit-Remaining: 52 X-RateLimit-Reset: 1705134976 X-RateLimit-Resource: core -X-RateLimit-Used: 6 +X-RateLimit-Used: 8 Accept-Ranges: bytes Content-Length: 479 -X-GitHub-Request-Id: 4759:B1098:F5468:107910:65A2435B +X-GitHub-Request-Id: 4739:3A5D83:1003B7A:111F7D9:65A24571 { "sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", From c3ef618aca126c9aaeb477ec54e4e7fe70d858d9 Mon Sep 17 00:00:00 2001 From: jiahao6635 Date: Sat, 13 Jan 2024 16:47:32 +0800 Subject: [PATCH 7/7] Change .Http Formatting --- .gitattributes | 5 +++++ .gitignore | 1 + tests/fixtures/scm/github/git/trees-success.http | 10 +++++----- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cb6dc10 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Denote all files that are truly binary and should not be modified. +*.http binary \ No newline at end of file diff --git a/.gitignore b/.gitignore index 088ba6b..aa982cd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk +.idea/ diff --git a/tests/fixtures/scm/github/git/trees-success.http b/tests/fixtures/scm/github/git/trees-success.http index 1f98979..bba8e6e 100644 --- a/tests/fixtures/scm/github/git/trees-success.http +++ b/tests/fixtures/scm/github/git/trees-success.http @@ -1,6 +1,6 @@ HTTP/1.1 200 OK Server: GitHub.com -Date: Sat, 13 Jan 2024 08:10:26 GMT +Date: Sat, 13 Jan 2024 08:20:49 GMT Content-Type: application/json; charset=utf-8 Cache-Control: public, max-age=60, s-maxage=60 Vary: Accept, Accept-Encoding, Accept, X-Requested-With @@ -17,13 +17,13 @@ X-XSS-Protection: 0 Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin Content-Security-Policy: default-src 'none' X-RateLimit-Limit: 60 -X-RateLimit-Remaining: 52 -X-RateLimit-Reset: 1705134976 +X-RateLimit-Remaining: 51 +X-RateLimit-Reset: 1705134977 X-RateLimit-Resource: core -X-RateLimit-Used: 8 +X-RateLimit-Used: 9 Accept-Ranges: bytes Content-Length: 479 -X-GitHub-Request-Id: 4739:3A5D83:1003B7A:111F7D9:65A24571 +X-GitHub-Request-Id: 47CE:382F98:220AD1D:2439E86:65A247E0 { "sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",