Merge pull request #15 from nix-community/manifest-formmatter

test & automate format of repos.json
This commit is contained in:
Jörg Thalheim 2018-07-01 13:58:01 +01:00 committed by GitHub
commit 92cc62fbf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 12 deletions

View file

@ -170,7 +170,8 @@ perform also an evaluation check, which must be passed for your repository. Comm
`repos.json` but NOT `repos.json.lock`
```
$ git add repo.json
$ git add repos.json
$ ./nur/format_repos_manifest # ensure repos.json is sorted alphabetically
$ git commit -m "add <your-repo-name> repository"
$ git push
```

View file

@ -14,6 +14,14 @@ fi
export encrypted_025d6e877aa4_key= encrypted_025d6e877aa4_iv=
./nur/format_repos_manifest
if [ -n "$(git diff --exit-code repos.json)" ]; then
echo "repos.json was not formatted before committing repos.json:" >&2
git diff --exit-code repos.json
echo "Please run ./nur/format_repos_manifest and updates repos.json accordingly!" >&2
exit 1
fi
./nur/update.py
nix-build

21
nur/format_repos_manifest Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env nix-shell
#!nix-shell -p python3 -i python3
import json
import shutil
from pathlib import Path
ROOT = Path(__file__).parent.parent
def main() -> None:
path = ROOT.joinpath("repos.json")
manifest = json.load(open(path))
tmp_path = str(path) + ".tmp"
with open(tmp_path, "w+") as tmp:
json.dump(manifest, tmp, indent=4, sort_keys=True)
shutil.move(tmp_path, path)
if __name__ == "__main__":
main()

View file

@ -148,7 +148,7 @@ def update_lock_file(repos: List[Repo]):
tmp_file = str(LOCK_PATH) + "-new"
with open(tmp_file, "w") as lock_file:
json.dump(dict(repos=locked_repos), lock_file, indent=4)
json.dump(dict(repos=locked_repos), lock_file, indent=4, sort_keys=True)
shutil.move(tmp_file, LOCK_PATH)

View file

@ -1,13 +1,13 @@
{
"repos": {
"dywedir":{
"dywedir": {
"url": "https://github.com/dywedir/nur-packages"
},
"mic92": {
"url": "https://github.com/Mic92/nur-packages"
},
"eeva": {
"url": "https://framagit.org/eeva/nur-packages"
},
"mic92": {
"url": "https://github.com/Mic92/nur-packages"
}
}
}
}

View file

@ -5,15 +5,15 @@
"sha256": "1kqvvprnvcnf6r482y9pyl0kd957kl129fx46v4vgvnql9a8rh19",
"url": "https://github.com/dywedir/nur-packages"
},
"mic92": {
"rev": "f16345720229519cc9e72167c187806829fd8fc5",
"sha256": "0birygrcrivzdah0y0bshphrrwsrk0bbba2yz6d2yqms193vbb0k",
"url": "https://github.com/Mic92/nur-packages"
},
"eeva": {
"rev": "1702147af6ec29a955b59c58da07a018c588e11d",
"sha256": "013dzdc1zwqpcsnsgx9b7qzzkha1rhwaq6jvaf3dq19jkwgddxl2",
"url": "https://framagit.org/eeva/nur-packages"
},
"mic92": {
"rev": "f16345720229519cc9e72167c187806829fd8fc5",
"sha256": "0birygrcrivzdah0y0bshphrrwsrk0bbba2yz6d2yqms193vbb0k",
"url": "https://github.com/Mic92/nur-packages"
}
}
}