-
Notifications
You must be signed in to change notification settings - Fork 5
Fix regex for new GitHub output of pull #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,14 @@ | ||
| v1.0.3 / 2022-01-29: | ||
|
|
||
| - GitHub output has changed, therefor regex syntax has to be corrected | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "therefor" should be "therefore" per Therefore vs. Therefor @ Grammarly
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, therefore of course. |
||
| + Request repo link from git remote, it is no longer in pullResult | ||
| + pullResult answer is now 'Updating FROMSHA..TO__SHA' | ||
| + also pullResult answer is localized! | ||
|
|
||
| v1.0.2 / 2017-03-06: | ||
|
|
||
| - Added the "from" key | ||
|
|
||
| v1.0.1 / 2012-01-31: | ||
|
|
||
| - Remove branch tags from log output (not that useful in github's wiki context) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| $path = null; | ||
| $email = null; | ||
| $subject = null; | ||
| $from = null; | ||
| foreach ($argv as $arg) | ||
| { | ||
| if (preg_match('/--path=(.*)/', $arg, $match)) { | ||
|
|
@@ -29,13 +30,15 @@ | |
| $email = $match[1]; | ||
| } else if (preg_match('/--subject=(.*)/', $arg, $match)) { | ||
| $subject = $match[1]; | ||
| } else if (preg_match('/--from=(.*)/', $arg, $match)) { | ||
| $from = $match[1]; | ||
| } | ||
| } | ||
|
|
||
| if (is_null($path) || is_null($email)) | ||
| if (is_null($path) || is_null($email) || is_null($from)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should For example, a I'm okay with requiring with the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, version can stay 1.x.x |
||
| { | ||
| echo("Usage:\n"); | ||
| echo(" " . basename(__FILE__) . " --path=/path/to/repo --email=list@example.com\n"); | ||
| echo(" " . basename(__FILE__) . " --path=/path/to/repo --email=list@example.com --from=my@email.com\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
|
|
@@ -44,18 +47,26 @@ | |
| exit(2); | ||
| } | ||
|
|
||
| // request repo-URL from git remote | ||
| $remote = `git remote -v`; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of this and regex below, would Example output of Example output of For an HTTPS checkout, the above would be: (But note that |
||
| $repo = 'unknown'; | ||
| if (preg_match('/origin\s*(\S*)\s*\(fetch\)\n/', $remote, $match)) | ||
| { | ||
| $repo = $match[1]; | ||
| } | ||
|
|
||
| $pullResult = `git pull 2>&1`; | ||
| if (preg_match('/From github\.com:(.*)\n\s*([^\s]+)/', $pullResult, $match)) | ||
| if (preg_match('/^\S* ([a-z0-9]{7}\.\.[a-z0-9]{7})\n/', $pullResult, $match)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if you restore all the other code (remove
So then
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With your notes I agree to give it a second try.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of just updating the regex. It focuses on the issue: Add support for HTTPS remotes (while keeping support for legacy/SSH ones). You can add a commit if that's easiest. I can squash merge into main branch. |
||
| { | ||
| $repo = $match[1]; | ||
| $revs = $match[2]; | ||
| $wikiDiffUrl = 'https://github.com/' . str_replace('.wiki', '/wiki', $repo) . '/_compare/' . $revs; | ||
| $revs = $match[1]; | ||
| $wikiDiffUrl = str_replace('.wiki.git', '/wiki', $repo) . '/_compare/' . $revs; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes the repo was checked out using HTTPS, which isn't a requirement. For example, an SSH clone like For HTTPS checkout that's: Perhaps we should be pulling And perhaps pull
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't consider SSH clone, as it needs to setup authentication on the host, what could be a security issue. |
||
| $changeLog = `git log --pretty=format:'%h - %s (%cr) <%an>' $revs`; | ||
|
|
||
| if (is_null($subject)) { | ||
| $subject = '[SCM]: ' . $repo . ' was updated'; | ||
| } | ||
| $body = "To see the changes, visit:\n" . $wikiDiffUrl . "\n\nChangelog:\n" . $changeLog . "\n"; | ||
| mail($email, $subject, $body, "From: $email"); | ||
| mail($email, $subject, $body, "From: $from"); | ||
| } | ||
| // else no updates | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be
v2.0.0 / ...since it introduces backwards incompatible changes (see comments below)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this should be
v2.0.1andv1.0.2below should bev2.0.0(if keeping the--fromrequirement)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last tagged version was
v1.0.1. Thev1.0.2I pulled in from ilyasergey/github-wiki-notify was never official or even tagged.So I suggest to collect changes and make this
v1.0.2with optional--from.