Getting specific part of text from file based on in-line date - shell

I am not savvy at all when it comes to scripting. The script I have basically dumps the results of git log command into a file.
However, I would only like to show the lines for the day the script was run. So if I run myscript.sh on Thu Jun 20, I want to see all lines from a file down until Wed Jun 19.
Here is what the file looks like:
commit 8da0dd9bsd23899d11b4ee7348af0640b98ed4b17
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Thu Jun 20 12:08:59 2013 -0400
Testing Git push 13 6
Multiple lines
commit aca564549f91329fcfa9a9f908f7fdeffa83f139b
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Thu Jun 20 12:01:48 2013 -0400
Testing Git push 13 5
commit b80c51b32f48364c2108588aff4c9e12fbb78370b
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Thu Jun 20 11:59:57 2013 -0400
Testing Git push 13 4
commit c4f8f8d4196f7c0f2deaf8g0ecc61797e7b8afdd9
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Wed Jun 19 11:48:37 2013 -0400
Testing Git push 13 3
commit 9a296b2273528868e3e4dc19310fa802daf76b1f3
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Wed Jun 19 11:45:49 2013 -0400
Testing Git push 13 2
commit 55cb8f2399242f051f577a042713a402137df4456
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Sat Jun 15 11:40:48 2013 -0400
Testing Git push 13 1
commit a48e59ec1de227cc2878dce3330ge7776336eb289
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Thu Jun 13 11:28:56 2013 -0400
Switched datasource to SuprPakJ
Created WWButton and WWLabel (extends JButton and JLabel)
Designed Sales Order screen
commit 57ce2da4673a35f50a5146d43a1f1a969c590c8c9
Author: Denis <Denis#WWOscar.Waudware.local>
Date: Tue Jun 11 08:20:58 2013 -0400
I tried searching, but best I got was the sed -e command to print out everything until the first blank line, which isn't exactly what I need.
Any help is appreciated!

How does this work for you:
git log --since=yesterday

Related

Git blame delivers different results in Gitlab CI than on local machine

I've created a small shell script that uses the output of git blame to generate some reports. This works great on my local machine. But then I wanted to integrate the shell script in our gitlab ci/cd pipeline and for some reason when I run git blame on gitlab, all lines are attributed to me and the latest commit.
This is what I put in my pipeline file to debug this issue:
run-git-blame:
stage: mystage
image: alpine
before_script:
- apk add bash git gawk
- git status
- git log
script:
- git blame HEAD -- somefile.txt
When I run git blame HEAD -- somefile.txt locally I get:
4588eb70a0b (DXXXXXXX 2019-05-07 15:35:22 +0200 1) abc=123
4588eb70a0b (DXXXXXXX 2019-05-07 15:35:22 +0200 2) def=456
4588eb70a0b (DXXXXXXX 2019-05-07 15:35:22 +0200 3) ghi=789
4588eb70a0b (DXXXXXXX 2019-05-07 15:35:22 +0200 4) jkl=abc
4588eb70a0b (DXXXXXXX 2019-05-07 15:35:22 +0200 5) mno=def
[...]
However the gitlab ci output looks like this:
^5e95b8e5 (Sebastian Gellweiler 2020-09-24 09:32:54 +0200 1) abc=123
^5e95b8e5 (Sebastian Gellweiler 2020-09-24 09:32:54 +0200 2) def=456
^5e95b8e5 (Sebastian Gellweiler 2020-09-24 09:32:54 +0200 3) ghi=789
^5e95b8e5 (Sebastian Gellweiler 2020-09-24 09:32:54 +0200 4) jkl=abc
^5e95b8e5 (Sebastian Gellweiler 2020-09-24 09:32:54 +0200 5) mno=def
[...]
Bu I have definitevly not touched the file being inspected.
The git status command outputs the following on the server:
HEAD detached at 5e95b8e5
nothing to commit, working tree clean
And this looks fine, as 5e95b8e5 is the hash of the latest commit.
What also puzzles me is the output of git log on gitlab because it only shows one commit and no history:
commit 5e95b8e5efcfd155d4248f4849b848e9f1580a20
Author: Sebastian Gellweiler <sebastian.gellweiler#dm.de>
Date: Thu Sep 24 09:32:54 2020 +0200
...
This is what the history on my local machine looks like:
commit 5e95b8e5efcfd155d4248f4849b848e9f1580a20 (HEAD -> feature/XXX)
Author: Sebastian Gellweiler <sebastian.gellweiler#example.org>
Date: Thu Sep 24 09:32:54 2020 +0200
...
commit bc689804f87d906e1b2435249fc1aaaf32e49b20
Author: Sebastian Gellweiler <sebastian.gellweiler#dm.de>
Date: Wed Sep 23 18:40:18 2020 +0200
XXX
commit 9d6fa2336aee0938aef0bd78563b6f12dee5934f (master)
Merge: 90ef282515 3eabec88c2
Author: XXXX <XXX#example.org>
Date: Thu Sep 17 08:31:20 2020 +0000
XYZ
[...]
As you can see the top commit hash is the same on my local machine and on the remote.
I'm stuck here. Anybody has an explanation for this discrepancy?
I think you have GitLab configured to make a shallow clone that has depth 1. Since it has only one commit, every file in the repository is the way it is due to the (single, one) commit that is in the repository, so that's the hash ID it produces.
In particular, this notation:
^5e95b8e5
indicates that Git knows there is something before 5e95b8e5, but not what it is, which in this case is the mark of a shallow repository. (Technically it's a boundary mark and you'd see it on some other commit if you had used a range expression, such as abc1def..HEAD. You can use the -b option, or some configuration items, to alter how these are shown.)
Git commits only connect to their parents, Git can only go through history backwards. If you have a commit checked out that's older than 5e95b8e5 you will not see it in git blame nor git log.
Alternatively, your local repo is out of datee and you need to git pull.

How can I find POEdit errors

I'm getting duplicate message definition errors in POEdit and I cannot update from that catalog.
POEdit doesn't show details and the line numbers in the errors don't match.
How can I find what is wrong?
Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:2791: duplicate message definition...
Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:65: ...this is the location of the first definition
Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:2827: duplicate message definition...
Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:1530: ...this is the location of the first definition
Sat Mar 11 16:51:31 2017: /Users/burakkilic/Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/msgmerge: found 2 fatal errors
Sat Mar 11 16:51:31 2017: Entries in the catalogue are probably incorrect.
Sat Mar 11 16:51:31 2017: Updating the catalogue failed. Click on 'Details >>' for details.
How can I find what is wrong?
msgfmt -v -c /path/to/1input.po

no ocijdbc12 in java.library.path sqldeveloper mac os

I am trying to get SQLDeveloper to work on my Mac laptop. I need to make a TNS connection but whenever I try to create one I get the error message: no ocijdbc12 in java.library.path.
I have latest instantclient installed and I only see these files:
instantclient_11_2:
total 380640
-rw-rw-rw-# 1 red staff 484 Apr 10 2014 BASIC_README
-rwxrwxrwx# 1 red staff 14348 Apr 10 2014 adrci
-rwxrwxrwx# 1 red staff 40768 Apr 10 2014 genezi
-r-xr-xr-x# 1 red staff 66167420 Feb 7 2014 libclntsh.dylib.11.1
-r-xr-xr-x# 1 red staff 2817872 Jan 29 2014 libnnz11.dylib
-r-xr-xr-x# 1 red staff 1897664 Feb 7 2014 libocci.dylib.11.1
-rwxrwxrwx# 1 red staff 118707148 Apr 10 2014 libociei.dylib
-r-xr-xr-x# 1 red staff 159004 Jan 7 2014 libocijdbc11.dylib
-r--r--r--# 1 red staff 2091135 Jan 28 2014 ojdbc5.jar
-r--r--r--# 1 red staff 2739616 Jan 28 2014 ojdbc6.jar
-rwxrwxrwx# 1 red staff 162380 Apr 10 2014 uidrvci
-r--r--r--# 1 red staff 66779 Jan 7 2014 xstreams.jar
There's a libocijdbc11.dylib but no libocijdbc12.dylib. What's up with that?
After a recent JAVA upgrade, my SqlDeveloper install stopped working, errors related to :
The native OCI driver could not be loaded. The system property java.library.path contains the entries from the environment variable 'DYLD_LIBRARY_PATH' check it to verify that the expected native library directory /usr/lib/java is present and precedes any other client installations.
I upgraded to SqlDeveloper 18.1.0 = no luck.
I tried many fixes - modifying '/.sqldeveloper/18.1.0/product.conf', futzing with $PATH, etc - they all failed
FINALLY - I upgraded the instant client to instantclient_12_2 IT WORKED!
Note - the place you set environment vars is now: ${HOME}/.sqldeveloper//env.sh
in my case, /Users/REDACTED/.sqldeveloper/18.1.0/env.sh contains:
export TNS_ADMIN="${HOME}/Downloads/instantclient_12_2"
export DYLD_LIBRARY_PATH=$TNS_ADMIN
export LD_LIBRARY_PATH=$TNS_ADMIN
export SQLPATH=$TNS_ADMIN
if ! echo $PATH | fgrep "${DYLD_LIBRARY_PATH}" /dev/null ; then
export PATH="${DYLD_LIBRARY_PATH}:${PATH}"
fi
This (using env.sh) is better than cluttering up your .bashrc files
My Solution:
Just use the setting in SQLDeveloper:
Tools > Preferences > Database > Advanced > Tnsnames Directory
Click Browse to select the location of the parent folder of your tnsnames file.

l10n support in ruby

I am able to parse localized dates using python locale module and posix localization database:
import locale, datetime
locale.setlocale(locale.LC_TIME, 'tr_TR.UTF-8')
print datetime.datetime.strptime("1 Haziran 2014", "%d %B %Y")
===
Edit
This example loads the locale and datetime modules, parses the localized date to create an instance of python's datetime class. I'm looking specifically for Ruby code that can parse localized dates using posix database.
===
Is there any equivalent of this in ruby? If there is a ruby library like python's locale module or Boost.Locale in C++, can you give example code? I tried the gettext gem and locale gem (I set current locale and tried Time.strptime, which failed).
I do not expect to do custom gsub or an i18n config file parsing. I am asking for code that uses posix database to parse dates.
You will need 2 custom gems in your Gemfile
Chronic:
$ git clone git://github.com/mojombo/chronic.git
$ cd chronic && gem build chronic.gemspec
$ gem install chronic-*.gem
Chronic-l10n:
$ git clone git://github.com/luan/chronic-l10n.git
$ cd chronic-l10n && gem build chronic-l10n.gemspec
$ gem install chronic-l10n-*.gem
Usage:
require 'chronic'
require 'chronic-l10n'
Time.now #=> Sun Aug 27 23:18:25 PDT 2006
Chronic.locale = :'pt-BR'
Chronic.parse('amanhã')
#=> Mon Aug 28 12:00:00 PDT 2006
Chronic.parse('segunda', :context => :past)
#=> Mon Aug 21 12:00:00 PDT 2006
Chronic.parse('essa terça 5:00')
#=> Tue Aug 29 17:00:00 PDT 2006
Chronic.parse('essa terça 5:00', :ambiguous_time_range => :none)
#=> Tue Aug 29 05:00:00 PDT 2006
Chronic.parse('27 de maio', :now => Time.local(2000, 1, 1))
#=> Sat May 27 12:00:00 PDT 2000
Chronic.parse('27 de maio', :guess => false)
#=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007
Chronic.parse('6/4/2012', :endian_precedence => :little)
#=> Fri Apr 06 00:00:00 PDT 2012
It seems there is currently no ruby gem or code that can load posix database and parse dates using strptime style flags. (copy-paste answer is not accepted)

How to create a new timezone in Ruby?

I want to create a timezone definition for UTC+n without any DST changes for our testing purposes, but haven't figured out how to do it. I'm using ActiveSupport::TimeZone, but it seems that it has a hard-coded list of time zones which cannot be programmatically extended.
In particular, however I try to create a new timezone, it is always missing DST information. If I provide an existing timezone as a basis, it ignores the time offset I provided instead.
Below are some attempts I tried to create a timezone in UTC+1:
> ActiveSupport::TimeZone[1].now
=> Tue, 06 Aug 2013 12:39:35 CEST +02:00
> ActiveSupport::TimeZone.create("UTC", 3600).now
=> Tue, 06 Aug 2013 10:39:40 UTC +00:00
> ActiveSupport::TimeZone.create("foo", 3600).now
TZInfo::InvalidTimezoneIdentifier: cannot load such file -- tzinfo/definitions/foo
> ActiveSupport::TimeZone.create("foo", 3600, TZInfo::Timezone.get("UTC")).now
=> Tue, 06 Aug 2013 10:39:48 UTC +00:00

Resources