Skip to content

Commit 9dc4d5f

Browse files
authored
Merge pull request bakaq#11 from constraintAutomaton/feature/hash-dependencies
Add the ability to use git dependencies with a fix hash
2 parents b2722cc + 5caabc2 commit 9dc4d5f

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies([
2727
```
2828

2929
Copy the `pkg.pl` file into your project. It is both the dependency manager and
30-
the package loader. Use `scryer-prolog pkg.pl -g pkg_install,halt` to download
30+
the package loader. Use `scryer-prolog pkg.pl -g pkg_install,halt.` to download
3131
the dependencies to a `scryer_libs` directory (it doesn't handle transitive
3232
dependencies yet). You can then import packages in your code as follows:
3333

example/main.pl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:- use_module(pkg(testing)).
77
:- use_module(pkg(foo_branch)).
88
:- use_module(pkg(foo_tag)).
9+
:- use_module(pkg(foo)).
910

1011
% You can then use the predicates exported by the main file of the dependency
1112
% in the rest of the program.
@@ -17,3 +18,5 @@
1718

1819
test("test if the branch dependency works", (tag(exist))).
1920
test("test if the tag dependency works", (branch(exist))).
21+
test("test if the hash dependency works", (hash(exist))).
22+

example/scryer-manifest.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
% A git url to clone at a specific branch
99
git("https://github.com/constraintAutomaton/test-prolog-package-manager.git", branch("branch")),
1010
% A git url to clone at a tag
11-
git("https://github.com/constraintAutomaton/test-prolog-package-manager.git", tag("tag"))
11+
git("https://github.com/constraintAutomaton/test-prolog-package-manager.git", tag("tag")),
12+
% A git url to clone at a specific commit hash
13+
git("https://github.com/constraintAutomaton/test-prolog-package-manager.git", hash("d19fefc1d7907f6675e181601bb9b8b94561b441"))
1214
]).

pkg.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,9 @@
9090

9191
git_command(git(Url, tag(Tag)), Command) :-
9292
git_command(git(Url, branch(Tag)), Command).
93+
94+
git_command(git(Url, hash(Hash)), Command) :-
95+
CloneCommand = ["git clone --quiet --depth 1 --single-branch ", Url, " scryer_libs/tmp "],
96+
GetHashCommitCommand = [" && cd scryer_libs/tmp >/dev/null && git fetch --quiet --depth 1 origin ", Hash, " && git checkout --quiet ", Hash, " && cd ../ >/dev/null"],
97+
append(CloneCommand, GetHashCommitCommand, Segments),
98+
append(Segments, Command).

0 commit comments

Comments
 (0)