> Did you add the risky tag too?
Done.
> I get a number of PRs nowadays which do one thing in 5/6 commits.
Yeah it's annoying when people don't rebase when they should.
> I do a squash merge nowadays.
Oh.
That's probably not a good idea for multi-commits PRs (unless the commits need squashing). Squashing unrelated commits makes bisecting a lot harder.
> So my take here is we are overdoing it.
Sure, that's a valid argument. If you're bothered by the complexity, feel free to roll back. (But do keep 6a3c025, that's an independent fix.)
> Probably 99% of the time they will tell us the release version.
Possible.
By the way, a little bit of context for improving version detection: it's really *really* hard to get people to provide adequate debugging information, even when you explicitly hand over an itemized list of things you need (proven time and again). So it's definitely a win if you can extract more of that info from a single command, rather than ask separately.
> You only get the benefit it you stick to one installation method. That is, you either download stable and upgrade to stable, or download git master and upgrade to master.
Actually that's not entirely accurate. Downloading stable then upgrading to git master is perfectly fine. But not the other way round.
> It shows the version only within the source directory. Will it be really useful at any point in time?
Useful for me at least. Or anyone who uses a symlink to the source directory.
> So the same file returns to v 2.9 outside the source directory and downgrades to v2.9 without any check.
Because it's impossible to check. That was the case too before this PR, so it's not a regression.
You only get the benefit it you stick to one installation method. That is, you either download stable and upgrade to stable, or download git master and upgrade to master. Downloading master first then trying to "upgrade" to stable doesn't help, and it's been the case all along.
@jarun Speaking of cutting a release, it's probably a good chance to give the [release checklist](https://github.com/jarun/googler/wiki/Release-checklist) a try and add any missing steps.
I also left a message on https://gitter.im/jarun/googler about the GitHub topics.
Include commit hash in version number when possible
===================================================
- In a git repo (that is, when `googler` — after symlink resolution — is a git repo), use `git-describe` (or `git-rev-parse` as fallback) on HEAD to determine the exact commit. Examples:
```
$ googler --version
2.9-21-g3f46a90
```
or when the clone is shallow, without tags:
```
$ ./googler --version
2.9-*-g3f46a90
```
Note that if HEAD is at an exact tag, you won't see that trailing `-<count>-g<sha>` (which is apparently preferable), simply due to how `git describe --abbrev HEAD` works.
- Outside a git repo, if the script is downloaded via `googler --upgrade --include-git`, we now put the commit hash into `_VERSION_`, also in the `<major>.<minor>-*-g<sha>` format seen in the shallow case above (since we can't get commit count since tag/release from GitHub API v3). Sample session:
```
$ ./googler -u --include-git
Upgrading from version 2.9-*-g3f46a90
Downloading https://raw.githubusercontent.com/jarun/googler/df256cf083488be6aa9ea4459b624e84802ab0df/googler
Upgraded to version 2.9-*-gdf256cf.
```
A nice bonus is we can now warn about downgrading from git master to stable (due to missing `--include-git`:
```
$ ./googler -u
Upgrading from version 2.9-*-g3f46a90
Downloading https://raw.githubusercontent.com/jarun/googler/v2.9/googler
[WARNING] 2.9-*-g3f46a90 => 2.9 may be a downgrade; did you forget --include-git?
Upgraded to version 2.9.
```
To be fair, maybe zero people will benefit from this (I'm afraid at most a handful users use `-u`, less `--include-git`), but IMO it's pretty neat from a design point of view. 💯
We have the `--json` option for structured output.
```json
$ googler --json google
[
{
"abstract": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking ...",
"sitelinks": [
{
"abstract": "More than letters and words. Google Docs brings your ...",
"index": "1a",
"title": "Docs",
"url": "https://www.google.com/docs/about/"
},
{
"abstract": "Personal info & privacy - My Activity - Find your phone - ...",
"index": "1b",
"title": "My Account",
"url": "https://myaccount.google.com/"
},
{
"abstract": "Free radio for everything you do. Store 50000 tracks from your ...",
"index": "1c",
"title": "My music",
"url": "https://play.google.com/music?authuser"
},
{
"abstract": "Drive starts you with 15 GB of free Google online storage, so you ...",
"index": "1d",
"title": "Google Drive",
"url": "https://www.google.com/drive/"
},
{
"abstract": "Google Images. The most comprehensive image search ...",
"index": "1e",
"title": "Google Images",
"url": "https://images.google.com/"
},
{
"abstract": "Google's free service instantly translates words, phrases, and ...",
"index": "1f",
"title": "Translate",
"url": "https://translate.google.com/"
}
],
"title": "Google",
"url": "https://www.google.com/"
},
{
"abstract": "",
"title": "Google (@Google) · Twitter",
"url": "https://twitter.com/Google?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor"
},
{
"abstract": "Experience the world of Google on our official YouTube channel. Watch videos about our products, technology, company happenings and more. Subscribe to ...",
"title": "Google - YouTube",
"url": "https://www.youtube.com/user/Google"
},
{
"abstract": "4 days ago - Discover all the latest about our products, technology, and Google culture on our official blog.",
"title": "The Keyword | Google",
"url": "https://blog.google/"
},
{
"abstract": "We invest in teams with bold ideas that create lasting impact on some of the world's biggest challenges.",
"title": "Google.org",
"url": "https://www.google.org/"
},
{
"abstract": "Search for and register a domain, get hosting, and build a site with Google Domains. The best of the internet backed by the security of Google.",
"title": "Google Domains – Google",
"url": "https://domains.google/"
}
]
```
Now, use any JSON parser you like, e.g., [jq](https://stedolan.github.io/jq/) (highly recommended):
```
$ googler --json google | jq -r '.[].url'
https://www.google.com/
https://twitter.com/Google?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor
https://www.youtube.com/user/Google
https://blog.google/
https://www.google.org/
https://domains.google/
```
or, including sitelinks:
```
$ googler --json google | jq -r '.[] | (.url, (.sitelinks|.[]?.url))'
https://www.google.com/
https://play.google.com/music?authuser
https://myaccount.google.com/
https://www.google.com/docs/about/
https://www.google.com/drive/
https://images.google.com/
https://www.google.com/intl/en/about/
https://twitter.com/Google?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor
https://www.youtube.com/user/Google
https://blog.google/
https://www.google.org/
https://domains.google/
```
I think that solves your problem, so I'm going to close this issue.
By the way, out of curiosity, why do you want to download random Google results with curl? Sounds very weird to me. It might be slightly more reasonable if you're feeding the results into one of those article scrapers.