-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let
#resolved_revision
return the last fetched commit
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,36 @@ def source(revision: 'b4d3b346d9657543099a35a1fd20347e75b8c523') | |
'repo_dir' => 'gems', | ||
}) | ||
end | ||
|
||
def git(*cmd, **opts) | ||
Open3.capture3("git", *cmd, **opts).then do |out, err, status| | ||
raise "Unexpected git status: \n\n#{err}" unless status.success? | ||
out | ||
end | ||
end | ||
|
||
def test_resolved_revision_updated_after_fetch | ||
Dir.mktmpdir do |dir| | ||
origin_repo = File.join(dir, "origin_repo") | ||
Dir.mkdir(origin_repo) | ||
git "init", chdir: origin_repo | ||
git "config", "user.email", "[email protected]", chdir: origin_repo | ||
git "config", "user.name", "Your Name", chdir: origin_repo | ||
git "checkout", "-b", "main", chdir: origin_repo | ||
|
||
git "commit", "--allow-empty", "-m", "Initial commit", chdir: origin_repo | ||
sha_initial_commit = git("rev-parse", "HEAD", chdir: origin_repo).chomp | ||
|
||
RBS::Collection::Sources::Git.new(name: "test", revision: "main", remote: origin_repo, repo_dir: "gems").tap do |source| | ||
assert_equal sha_initial_commit, source.resolved_revision | ||
end | ||
|
||
git "commit", "--allow-empty", "-m", "Second commit", chdir: origin_repo | ||
sha_second_commit = git("rev-parse", "HEAD", chdir: origin_repo).chomp | ||
|
||
RBS::Collection::Sources::Git.new(name: "test", revision: "main", remote: origin_repo, repo_dir: "gems").tap do |source| | ||
assert_equal sha_second_commit, source.resolved_revision | ||
end | ||
end | ||
end | ||
end |