Skip to content

Commit

Permalink
Merge rust-bitcoin#3793: Update regex lookahead to match when there a…
Browse files Browse the repository at this point in the history
…re no characters

23f75a0 Update regex lookahead to match when there are no characters (Shing Him Ng)

Pull request description:

  Was working on rust-bitcoin#3777 and noticed that `amount::Denomination` didn't show up when running `contrib/api.sh units types`. There are some structs/enums in `api/<crate>/all-features.txt` that dont have a `\(`, `;`, or ` ` after the struct/enum name, and the line just ends, so matching the end of line `$` should also be added.

  This allows the script to find the additional type from `units`:
  `#[non_exhaustive] pub enum bitcoin_units::amount::Denomination`

  Also tested this in `primitives`, and it returned:
  ```
  script::Script
  BlockChecked
  BlockUnchecked
  absolute::LockTime
  block::Checked
  block::Unchecked
  locktime::absolute::LockTime
  locktime::relative::LockTime
  opcodes::Class
  opcodes::ClassifyContext
  relative::LockTime
  BlockHash
  BlockHeader
  CompactTarget
  Sequence
  TapBranchTag
  TapLeafHash
  TapLeafTag
  TapNodeHash
  TapTweakHash
  TapTweakTag
  Transaction
  TxIn
  TxMerkleNode
  TxOut
  Txid
  Witness
  WitnessCommitment
  WitnessMerkleNode
  Wtxid
  block::BlockHash
  block::Header
  block::Version
  block::WitnessCommitment
  merkle_tree::TxMerkleNode
  merkle_tree::WitnessMerkleNode
  opcodes::Opcode
  pow::CompactTarget
  script::ScriptBuf
  script::ScriptHash
  script::WScriptHash
  sequence::Sequence
  taproot::TapBranchTag
  taproot::TapLeafHash
  taproot::TapLeafTag
  taproot::TapNodeHash
  taproot::TapTweakHash
  taproot::TapTweakTag
  transaction::OutPoint
  transaction::Transaction
  transaction::TxIn
  transaction::TxOut
  transaction::Txid
  transaction::Version
  transaction::Wtxid
  witness::Witness
  ```

  vs without this update (on `master`):
  ```
  script::Script
  BlockHash
  CompactTarget
  Sequence
  TapLeafHash
  TapNodeHash
  TapTweakHash
  TxMerkleNode
  Txid
  WitnessCommitment
  WitnessMerkleNode
  Wtxid
  block::BlockHash
  block::Version
  block::WitnessCommitment
  merkle_tree::TxMerkleNode
  merkle_tree::WitnessMerkleNode
  pow::CompactTarget
  script::ScriptBuf
  script::ScriptHash
  script::WScriptHash
  sequence::Sequence
  taproot::TapLeafHash
  taproot::TapNodeHash
  taproot::TapTweakHash
  transaction::Txid
  transaction::Version
  transaction::Wtxid
  ```

ACKs for top commit:
  tcharding:
    ACK 23f75a0
  storopoli:
    ACK 23f75a0
  apoelstra:
    ACK 23f75a0; successfully ran local tests

Tree-SHA512: ce6a43d017bb4bc6317853a4646ce4a8dcf5ce957bb2b9cc50bbd333c6854efd7527c25571c1b30736ae496305fedcf876022ad26c50bee232150d308cb62d08
  • Loading branch information
apoelstra committed Dec 20, 2024
2 parents 229aa01 + 23f75a0 commit 989db7c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ main() {

# Print all public structs and enums.
structs_and_enums() {
grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| )' "$file" | sed "s/^${crate_full_name}:://"
grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://"
}

# Print all public structs and enums excluding error types.
structs_and_enums_no_err() {
grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| )' "$file" | sed "s/^${crate_full_name}:://" | grep -v Error
grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://" | grep -v Error
}

# Print all public traits.
Expand Down

0 comments on commit 989db7c

Please sign in to comment.