-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6708c03
commit 473cda1
Showing
33 changed files
with
68 additions
and
44 deletions.
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
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 |
---|---|---|
@@ -1,13 +1,32 @@ | ||
package g | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
) | ||
|
||
func TestLookup(t *testing.T) { | ||
Configure() | ||
sha, err := ShaFromHexString("d208f34d505adb8914e5a5c577c6db8359173b4e") | ||
//sha, err := ShaFromHexString("ebf679b4719cb6df2e6d9f8a471353abae08cf98") | ||
func TestPackfile_lookupInPackfiles(t *testing.T) { | ||
if err := Configure( | ||
WithPath("./test_assets/repo/test-pack-file"), | ||
WithGitDirectory(".gitg"), | ||
); err != nil { | ||
t.Fatal(err) | ||
} | ||
sha, err := ShaFromHexString("132fa1c9e9de4d67a0037f9ca1f143b09cccd704") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
obj, err := lookupInPackfiles(sha) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
lookupInPackfiles(sha) | ||
if obj.Typ != ObjectTypeCommit { | ||
t.Errorf("typ = %d, want %d", obj.Typ, ObjectTypeCommit) | ||
} | ||
files, err := CurrentStatus() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if files.Files()[0].IdxStatus != IndexNotUpdated { | ||
t.Errorf("idxStatus = %d, want %d", files.Files()[0].IdxStatus, IndexNotUpdated) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package g | ||
|
||
func CurrentStatus() (*FileSet, error) { | ||
// index | ||
idx, err := ReadIndex() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
commitSha, err := LastCommit() | ||
if err != nil { | ||
// @todo error types to check for e.g no previous commits as source of error | ||
return nil, err | ||
} | ||
return Status(idx, commitSha) | ||
} | ||
|
||
// Status returns a FileSet containing all files from commit, index and working directory | ||
// with the corresponding status. | ||
func Status(idx *Index, commitSha Sha) (*FileSet, error) { | ||
var commitFiles []*File | ||
var err error | ||
if commitSha.IsSet() { | ||
commitFiles, err = CommittedFiles(commitSha) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
files := NewFileSet(commitFiles) | ||
files.MergeFromIndex(NewFileSet(idx.Files())) | ||
workingDirectoryFiles, err := Ls(Path()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
files.MergeFromWD(NewFileSet(workingDirectoryFiles)) | ||
return files, nil | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# pack-refs with: peeled fully-peeled sorted | ||
132fa1c9e9de4d67a0037f9ca1f143b09cccd704 refs/heads/main |
Empty file.