Skip to content

Commit

Permalink
Merge pull request #22 from jiahao6635/master
Browse files Browse the repository at this point in the history
check for updates
  • Loading branch information
wangeguo authored Jan 13, 2024
2 parents 3946953 + c3ef618 commit daf11cf
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
.idea/
7 changes: 3 additions & 4 deletions src/scm/driver/github/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -85,9 +85,8 @@ impl GitService for GithubGitService {
let recursive = recursive.unwrap_or(true);
options.insert(String::from("recursive"), recursive.to_string());
let res = self.client.get::<TreeResponseEndpoint>(&path, Some(options))?;
Ok(res.data.map(|v| v.into()))
Ok(res.data)
}

}

#[derive(Debug, Deserialize, Serialize)]
Expand Down
7 changes: 6 additions & 1 deletion src/scm/driver/gitlab/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>) -> anyhow::Result<Option<Tree>> {
fn git_trees(
&self,
_repo: &str,
_tree_sha: &str,
_recursive: Option<bool>,
) -> anyhow::Result<Option<Tree>> {
todo!()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/scm/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 12 Jan 2024 15:29:06 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
ETag: W/"122c1cb1624fc0caae5bb8a69852b535c721ce8ecddd2db05374e5d2c699cf61"
Last-Modified: Fri, 12 Jan 2024 05:37:27 GMT
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
Expand All @@ -16,15 +16,14 @@ 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-Remaining: 51
X-RateLimit-Reset: 1705134977
X-RateLimit-Resource: core
X-RateLimit-Used: 5
X-RateLimit-Used: 9
Accept-Ranges: bytes
Content-Length: 231
X-GitHub-Request-Id: E91C:2E0C86:C27F85A:C4AA8BD:65A15AC2
Content-Length: 479
X-GitHub-Request-Id: 47CE:382F98:220AD1D:2439E86:65A247E0

{
"sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",
Expand All @@ -41,4 +40,3 @@ X-GitHub-Request-Id: E91C:2E0C86:C27F85A:C4AA8BD:65A15AC2
],
"truncated": false
}

5 changes: 2 additions & 3 deletions tests/scm/driver/github/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -66,9 +66,8 @@ 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());

}

0 comments on commit daf11cf

Please sign in to comment.