tomnomnom/gf

Missing + to regexp s3-buckets

Closed this issue · 4 comments

Current rules:

{
    "flags": "-hrioaE",
    "patterns": [
        "[a-z0-9.-]+\\.s3\\.amazonaws\\.com",
        "[a-z0-9.-]+\\.s3-[a-z0-9-]\\.amazonaws\\.com",
        "[a-z0-9.-]+\\.s3-website[.-](eu|ap|us|ca|sa|cn)",
        "//s3\\.amazonaws\\.com/[a-z0-9._-]+",
        "//s3-[a-z0-9-]+\\.amazonaws\\.com/[a-z0-9._-]+"
    ]
}

If I have a text file that contains:

S3 bucket: bucketname1.s3.amazonaws.com/xxxxx
S3 bucket: https://s3.amazonaws.com/bucketname2/xxxxx
S3 bucket: http://s3-us-east-2.amazonaws.com/bucketname3/xxxxx
S3 bucket: http://bucketname4.s3-ca-central-1.amazonaws.com/xxxxx

The current rule returns 3 buckets:

$ gf s3-buckets dummy.txt 
bucketname1.s3.amazonaws.com
//s3.amazonaws.com/bucketname2
//s3-us-east-2.amazonaws.com/bucketname3

By adding a single + to the second rule:

"[a-z0-9.-]+\\.s3-[a-z0-9-]+\\.amazonaws\\.com",

I get all of them:

$ gf s3-buckets dummy.txt 
bucketname1.s3.amazonaws.com
//s3.amazonaws.com/bucketname2
//s3-us-east-2.amazonaws.com/bucketname3
bucketname4.s3-ca-central-1.amazonaws.com

@gwen001 I was just wondering what is the difference between github-history.py and gf for searching for certain pattern

It's not about the patterns, you set your own patterns. gf is like a grep -r <dir> while github-history.py search through the commits (not the files) of a given repository.

@gwen001 Thx for explanation, so what about I want to search inside the whole git log!

What about: git log | grep xxx