Skip to content

Commit

Permalink
Improve support for git reference kinds (branch, tag, rev), imp…
Browse files Browse the repository at this point in the history
…rove fetching behaviour (#1045)

* Add proper support for git reference kinds (`branch`, `tag`, `rev`)

Works toward resolving #1019, however tests and examples still need to
be updated.

Previously, we initialised the temporary git repository with a `clone`
operation. By default, this only fetches a subset of git references,
meaning that using references other than those provided by default with
`clone` failed to resolve.

Inspired by cargo, this commit updates the behaviour to instead first
initialise the repository, then attempt to fetch only those references
that are relevant to the user specified git reference.

In order to construct an accurate set of `refspecs` and fetch only the
relevant commits, its useful to retain knowledge about the *kind* of git
reference. This introduces a new `GitReference` type and updates the git
source lock file serialization to account for this.

* Update example `Forc.lock` files for git reference changes

* Update E2E test `Forc.lock` files for git reference changes

* Validate the commit hash while parsing `SourceGitPinned` from str
  • Loading branch information
mitchmindtree authored Mar 28, 2022
1 parent 5840399 commit cf5c3d1
Show file tree
Hide file tree
Showing 74 changed files with 466 additions and 321 deletions.
8 changes: 4 additions & 4 deletions examples/counter/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[[package]]
name = 'core'
source = 'git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44'
source = 'git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f'
dependencies = []

[[package]]
name = 'counter'
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8']
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3']

[[package]]
name = 'std'
source = 'git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44']
source = 'git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f']
8 changes: 4 additions & 4 deletions examples/fizzbuzz/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[[package]]
name = 'core'
source = 'git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44'
source = 'git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f'
dependencies = []

[[package]]
name = 'fizzbuzz'
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8']
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3']

[[package]]
name = 'std'
source = 'git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44']
source = 'git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f']
8 changes: 4 additions & 4 deletions examples/hello_world/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[[package]]
name = 'core'
source = 'git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44'
source = 'git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f'
dependencies = []

[[package]]
name = 'hello_world'
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8']
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3']

[[package]]
name = 'std'
source = 'git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44']
source = 'git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f']
8 changes: 4 additions & 4 deletions examples/subcurrency/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[[package]]
name = 'core'
source = 'git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44'
source = 'git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f'
dependencies = []

[[package]]
name = 'std'
source = 'git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44']
source = 'git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f']

[[package]]
name = 'subcurrency'
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8']
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3']
1 change: 1 addition & 0 deletions examples/subcurrency/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ contract;

use std::chain::*;
use std::hash::*;
use std::panic::panic;
use std::storage::*;
use std::address::Address;

Expand Down
8 changes: 4 additions & 4 deletions examples/wallet_smart_contract/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[[package]]
name = 'core'
source = 'git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44'
source = 'git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f'
dependencies = []

[[package]]
name = 'std'
source = 'git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?reference=master#30274cf817c1848e28f984c2e8703eb25e7a3a44']
source = 'git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3'
dependencies = ['core git+https://github.com/FuelLabs/sway-lib-core?branch=master#082bc8eb0616586ac0000825bfe6e9d47b0c713f']

[[package]]
name = 'wallet_smart_contract'
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?reference=master#aa36aea9362575c769781e7ab640d1d75dce13c8']
dependencies = ['std git+https://github.com/FuelLabs/sway-lib-std?branch=master#3884e9bbadb7c2567700dae847017366629241d3']
1 change: 1 addition & 0 deletions forc-pkg/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub struct DependencyDetails {
pub(crate) branch: Option<String>,
pub(crate) tag: Option<String>,
pub(crate) package: Option<String>,
pub(crate) rev: Option<String>,
}

impl Dependency {
Expand Down
Loading

0 comments on commit cf5c3d1

Please sign in to comment.