-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
199 changed files
with
1,848 additions
and
339 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,57 @@ | ||
author: ZomboDB, LLC | ||
ident: MIT | ||
email: [email protected] | ||
change_in_place: true | ||
excludes: | ||
- Cargo.toml | ||
- ".*\\.h" | ||
- "\\.cargo/config" | ||
- Cargo.lock | ||
- LICENSE | ||
- pgx-utils/assets/ansi.tmTheme | ||
- ".envrc" | ||
- ".gitignore" | ||
- "flake\\..*" | ||
- "logo.*" | ||
- ".github/**/*" | ||
- ".cargo/config" | ||
- "cargo-pgx/src/templates/*" | ||
- ".github/workflows/*" | ||
- ".*\\.control" | ||
- ".*\\.md" | ||
- ".*\\.nix" | ||
- ".*\\.yml" | ||
- ".*\\.sh" | ||
- load-order.txt | ||
licenses: | ||
- files: any | ||
ident: MIT | ||
authors: | ||
- name: Technology Concepts & Design, Inc. | ||
email: [email protected] | ||
template: | | ||
Portions Copyright 2019-2021 ZomboDB, LLC. | ||
Portions Copyright 2021-[year] [name of author] | ||
All rights reserved. | ||
Use of this source code is governed by the [ident] license that can be found in the LICENSE file. | ||
comments: | ||
- columns: 120 | ||
extensions: | ||
- rs | ||
- c | ||
- h | ||
- sql | ||
commenter: | ||
type: block | ||
start_block_char: "/*\n" | ||
end_block_char: "\n*/\n" | ||
- columns: 120 | ||
extension: html | ||
commenter: | ||
type: block | ||
start_block_char: "<!--\n" | ||
end_block_char: "-->" | ||
- columns: 80 | ||
extension: any | ||
commenter: | ||
type: line | ||
comment_char: "#" | ||
trailing_lines: 0 | ||
|
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,6 +1,8 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 ZomboDB, LLC | ||
Portions Copyright 2019-2021 ZomboDB, LLC. | ||
Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <[email protected]>. | ||
All rights reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
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 |
---|---|---|
|
@@ -273,6 +273,8 @@ time goes on. Your feedback about what you'd like to be able to do with `pgx` i | |
## License | ||
|
||
``` | ||
Copyright 2020 ZomboDB, LLC <[email protected]>. All rights reserved. | ||
Portions Copyright 2019-2021 ZomboDB, LLC. | ||
Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <[email protected]>. | ||
All rights reserved. | ||
Use of this source code is governed by the MIT license that can be found in the LICENSE 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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
// Copyright 2020 ZomboDB, LLC <[email protected]>. All rights reserved. Use of this source code is | ||
// governed by the MIT license that can be found in the LICENSE file. | ||
/* | ||
Portions Copyright 2019-2021 ZomboDB, LLC. | ||
Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <[email protected]> | ||
All rights reserved. | ||
Use of this source code is governed by the MIT license that can be found in the LICENSE file. | ||
*/ | ||
|
||
use crate::{ | ||
command::{get::get_property, run::exec_psql, start::start_postgres}, | ||
|
@@ -47,11 +53,13 @@ impl CommandExecute for Connect { | |
// It's actually the dbname! We should infer from the manifest. | ||
self.dbname = Some(pg_version); | ||
|
||
let metadata = crate::metadata::metadata(&Default::default(), self.manifest_path.as_ref()) | ||
.wrap_err("couldn't get cargo metadata")?; | ||
let metadata = | ||
crate::metadata::metadata(&Default::default(), self.manifest_path.as_ref()) | ||
.wrap_err("couldn't get cargo metadata")?; | ||
crate::metadata::validate(&metadata)?; | ||
let package_manifest_path = crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
let package_manifest_path = | ||
crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
let package_manifest = Manifest::from_path(&package_manifest_path) | ||
.wrap_err("Couldn't parse manifest")?; | ||
|
||
|
@@ -62,11 +70,13 @@ impl CommandExecute for Connect { | |
}, | ||
None => { | ||
// We should infer from the manifest. | ||
let metadata = crate::metadata::metadata(&Default::default(), self.manifest_path.as_ref()) | ||
.wrap_err("couldn't get cargo metadata")?; | ||
let metadata = | ||
crate::metadata::metadata(&Default::default(), self.manifest_path.as_ref()) | ||
.wrap_err("couldn't get cargo metadata")?; | ||
crate::metadata::validate(&metadata)?; | ||
let package_manifest_path = crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
let package_manifest_path = | ||
crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
let package_manifest = Manifest::from_path(&package_manifest_path) | ||
.wrap_err("Couldn't parse manifest")?; | ||
|
||
|
@@ -80,16 +90,18 @@ impl CommandExecute for Connect { | |
Some(dbname) => dbname, | ||
None => { | ||
// We should infer from package | ||
let metadata = crate::metadata::metadata(&Default::default(), self.manifest_path.as_ref()) | ||
.wrap_err("couldn't get cargo metadata")?; | ||
let metadata = | ||
crate::metadata::metadata(&Default::default(), self.manifest_path.as_ref()) | ||
.wrap_err("couldn't get cargo metadata")?; | ||
crate::metadata::validate(&metadata)?; | ||
let package_manifest_path = crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
let package_manifest_path = | ||
crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
|
||
get_property(&package_manifest_path, "extname") | ||
.wrap_err("could not determine extension name")? | ||
.ok_or(eyre!("extname not found in control file"))? | ||
}, | ||
} | ||
}; | ||
|
||
connect_psql(Pgx::from_config()?.get(&pg_version)?, &dbname) | ||
|
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,14 +1,20 @@ | ||
// Copyright 2020 ZomboDB, LLC <[email protected]>. All rights reserved. Use of this source code is | ||
// governed by the MIT license that can be found in the LICENSE file. | ||
/* | ||
Portions Copyright 2019-2021 ZomboDB, LLC. | ||
Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <[email protected]> | ||
All rights reserved. | ||
Use of this source code is governed by the MIT license that can be found in the LICENSE file. | ||
*/ | ||
|
||
use crate::CommandExecute; | ||
use eyre::{eyre, WrapErr}; | ||
use std::{ | ||
fs::File, | ||
io::{BufRead, BufReader}, | ||
path::{Path, PathBuf}, | ||
process::Command, | ||
}; | ||
use crate::CommandExecute; | ||
|
||
/// Get a property from the extension control file | ||
#[derive(clap::Args, Debug)] | ||
|
@@ -32,8 +38,9 @@ impl CommandExecute for Get { | |
let metadata = crate::metadata::metadata(&Default::default(), self.manifest_path.as_ref()) | ||
.wrap_err("couldn't get cargo metadata")?; | ||
crate::metadata::validate(&metadata)?; | ||
let package_manifest_path = crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
let package_manifest_path = | ||
crate::manifest::manifest_path(&metadata, self.package.as_ref()) | ||
.wrap_err("Couldn't get manifest path")?; | ||
|
||
if let Some(value) = get_property(&package_manifest_path, &self.name)? { | ||
println!("{}", value); | ||
|
@@ -79,30 +86,48 @@ pub fn get_property(manifest_path: impl AsRef<Path>, name: &str) -> eyre::Result | |
Ok(None) | ||
} | ||
|
||
pub(crate) fn find_control_file(manifest_path: impl AsRef<Path>) -> eyre::Result<(PathBuf, String)> { | ||
let parent = manifest_path | ||
.as_ref() | ||
.parent() | ||
.ok_or_else(|| eyre!("could not get parent of `{}`", manifest_path.as_ref().display()))?; | ||
|
||
for f in std::fs::read_dir(parent) | ||
.wrap_err_with(|| eyre!("cannot open current directory `{}` for reading", parent.display()))? { | ||
pub(crate) fn find_control_file( | ||
manifest_path: impl AsRef<Path>, | ||
) -> eyre::Result<(PathBuf, String)> { | ||
let parent = manifest_path.as_ref().parent().ok_or_else(|| { | ||
eyre!( | ||
"could not get parent of `{}`", | ||
manifest_path.as_ref().display() | ||
) | ||
})?; | ||
|
||
for f in std::fs::read_dir(parent).wrap_err_with(|| { | ||
eyre!( | ||
"cannot open current directory `{}` for reading", | ||
parent.display() | ||
) | ||
})? { | ||
if f.is_ok() { | ||
if let Ok(f) = f { | ||
let f_path = f.path(); | ||
if f_path.extension() == Some("control".as_ref()) { | ||
let file_stem = f_path.file_stem() | ||
.ok_or_else(|| eyre!("could not get file stem of `{}`", f_path.display()))?; | ||
let file_stem = file_stem.to_str() | ||
.ok_or_else(|| eyre!("could not get file stem as String from `{}`", f_path.display()))? | ||
let file_stem = f_path.file_stem().ok_or_else(|| { | ||
eyre!("could not get file stem of `{}`", f_path.display()) | ||
})?; | ||
let file_stem = file_stem | ||
.to_str() | ||
.ok_or_else(|| { | ||
eyre!( | ||
"could not get file stem as String from `{}`", | ||
f_path.display() | ||
) | ||
})? | ||
.to_string(); | ||
return Ok((f_path, file_stem)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
Err(eyre!("control file not found in `{}`", manifest_path.as_ref().display())) | ||
Err(eyre!( | ||
"control file not found in `{}`", | ||
manifest_path.as_ref().display() | ||
)) | ||
} | ||
|
||
fn determine_git_hash() -> eyre::Result<Option<String>> { | ||
|
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,5 +1,11 @@ | ||
// Copyright 2020 ZomboDB, LLC <[email protected]>. All rights reserved. Use of this source code is | ||
// governed by the MIT license that can be found in the LICENSE file. | ||
/* | ||
Portions Copyright 2019-2021 ZomboDB, LLC. | ||
Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <[email protected]> | ||
All rights reserved. | ||
Use of this source code is governed by the MIT license that can be found in the LICENSE file. | ||
*/ | ||
|
||
use crate::command::stop::stop_postgres; | ||
use crate::CommandExecute; | ||
|
@@ -435,7 +441,8 @@ pub(crate) fn initdb(bindir: &PathBuf, datadir: &PathBuf) -> eyre::Result<()> { | |
let command_str = format!("{:?}", command); | ||
tracing::debug!(command = %command_str, "Running"); | ||
|
||
let output = command.output() | ||
let output = command | ||
.output() | ||
.wrap_err_with(|| eyre!("unable to execute: {}", command_str))?; | ||
tracing::trace!(command = %command_str, status_code = %output.status, "Finished"); | ||
|
||
|
Oops, something went wrong.