Skip to content

Commit

Permalink
[cli] Add extra ignores to .gitignores created by CLI (#15674)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnazario authored Jan 7, 2025
1 parent e3fdc51 commit 0318475
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/aptos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ diesel-async = { workspace = true }
dirs = { workspace = true }
futures = { workspace = true }
hex = { workspace = true }
indoc = { workspace = true }
itertools = { workspace = true }
maplit = { workspace = true }
move-binary-format = { workspace = true }
Expand Down
15 changes: 14 additions & 1 deletion crates/aptos/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use aptos_vm_types::output::VMOutput;
use async_trait::async_trait;
use clap::{Parser, ValueEnum};
use hex::FromHexError;
use indoc::indoc;
use move_core_types::{
account_address::AccountAddress, language_storage::TypeTag, vm_status::VMStatus,
};
Expand Down Expand Up @@ -79,6 +80,18 @@ pub const DEFAULT_EXPIRATION_SECS: u64 = 30;
pub const DEFAULT_PROFILE: &str = "default";
pub const GIT_IGNORE: &str = ".gitignore";

pub const APTOS_FOLDER_GIT_IGNORE: &str = indoc! {"
*
testnet/
config.yaml
"};
pub const MOVE_FOLDER_GIT_IGNORE: &str = indoc! {"
.aptos/
build/
.coverage_map.mvcov
.trace"
};

// Custom header value to identify the client
const X_APTOS_CLIENT_VALUE: &str = concat!("aptos-cli/", env!("CARGO_PKG_VERSION"));

Expand Down Expand Up @@ -392,7 +405,7 @@ impl CliConfig {
write_to_user_only_file(
aptos_folder.join(GIT_IGNORE).as_path(),
GIT_IGNORE,
"*\ntestnet/\nconfig.yaml".as_bytes(),
APTOS_FOLDER_GIT_IGNORE.as_bytes(),
)?;
}

Expand Down
8 changes: 7 additions & 1 deletion crates/aptos/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
common::{
types::{
CliCommand, CliConfig, CliError, CliResult, CliTypedResult, ConfigSearchMode,
ProfileSummary, CONFIG_FOLDER,
ProfileSummary, APTOS_FOLDER_GIT_IGNORE, CONFIG_FOLDER, GIT_IGNORE,
},
utils::{create_dir_if_not_exist, current_dir, read_from_file, write_to_user_only_file},
},
Expand Down Expand Up @@ -369,6 +369,12 @@ impl GlobalConfig {
global_folder.join(GLOBAL_CONFIG_FILE).as_path(),
"Global Config",
&to_yaml(&self)?.into_bytes(),
)?;
// Let's also write a .gitignore that ignores this folder
write_to_user_only_file(
global_folder.join(GIT_IGNORE).as_path(),
".gitignore",
APTOS_FOLDER_GIT_IGNORE.as_bytes(),
)
}
}
Expand Down

0 comments on commit 0318475

Please sign in to comment.