Git提交计算一天

时间:2016-03-03 10:06:34

标签: git commit

我有一个名为git shortlog -s -n 的分支。现在我想知道每天发生了多少次提交(即每天)。

我想要Toal的提交次数(即)一天中的提交次数。

我尝试了这个命令,但是它提供了来自分支的所有提交计数

//
//  notification.swift
//  NSFetchController Pro
//
//  Created by Mr.Geeker on 08/02/15.
//  Copyright (c) 2015 X2coder. All rights reserved.
//

import UIKit

class notification {


    func createNotification(#hour:String, day:String, msgBody:String)->Bool
    {
        if(self.checkifNotificationOnOrOff())

        {



            //println("\(araToString(hour))")

            var dateFormatter:NSDateFormatter = NSDateFormatter()

            dateFormatter.locale = NSLocale.currentLocale()
            dateFormatter.dateStyle = NSDateFormatterStyle.NoStyle
            dateFormatter.timeStyle = NSDateFormatterStyle.ShortStyle
            var convertedTime:String = ""

            var testDate:NSDate = NSDate()

            var timeFormat:NSString = dateFormatter.stringFromDate(testDate)

            // Get the range of date (AM OR PM )
            var amRange:NSRange = timeFormat.rangeOfString(dateFormatter.AMSymbol)
            var pmRange:NSRange = timeFormat.rangeOfString(dateFormatter.PMSymbol)

            var is24h:Bool = (amRange.location == NSNotFound && pmRange.location == NSNotFound)
            if is24h {

                araToString(hour)

            }else{

                var dateFormatter2:NSDateFormatter = NSDateFormatter()
                dateFormatter2.dateFormat = "HH:mm"

                var hourDate:NSDate = dateFormatter2.dateFromString(hour)!

                var pmAmDateString:NSString = dateFormatter2.stringFromDate(hourDate)

                convertedTime = pmAmDateString
                println(convertedTime)

            }


            var hourAndMiOnly:NSArray = convertedTime.componentsSeparatedByString(":")
            var onlyHour:Int = 0
            var onlyMinuts:Int = 0

            for var i:Int = 0; i < 2; i++ {

                for  thimes in hourAndMiOnly
                {
                    if i == 0
                    {
                        onlyMinuts = thimes.integerValue

                    }
                    if i == 1 {
                        // we should add -1 before the class
                        onlyHour = (thimes.integerValue)
                        if onlyHour < 1
                        {
                            onlyHour = 00
                        }
                        break
                    }

                }
            }


            let DaysDic = [0:"None",1:"Sunday",2 :"Monday",3 :"Tuesday",4 :"Wednesday",5 :"Thursday",6 :"Friday",7 :"Saturday"]

            var ConvertDayToInt:Int?{

                for (key,value) in DaysDic
                {
                    if value == day
                    {
                        return key
                    }

                }
                return nil
            }

            //println("Hour is \(onlyHour) And Minut \(onlyMinuts) AND Day \(ConvertDayToInt)")

            let date = NSDate()
            var userInfo: [NSObject : AnyObject]?

            var createCalender:NSCalendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)!
            var dateComponenet:NSDateComponents = createCalender.components(NSCalendarUnit.YearCalendarUnit | NSCalendarUnit.WeekCalendarUnit, fromDate: date)
            dateComponenet.weekday = ConvertDayToInt!
            dateComponenet.hour = onlyHour
            dateComponenet.minute = onlyMinuts


            var fireDateToRun:NSDate = createCalender.dateFromComponents(dateComponenet)!

            var notificationClass:UILocalNotification = UILocalNotification()
            notificationClass.alertBody = msgBody
            notificationClass.fireDate  = fireDateToRun
            notificationClass.soundName = UILocalNotificationDefaultSoundName
            notificationClass.repeatInterval = NSCalendarUnit.WeekCalendarUnit
            notificationClass.timeZone = NSTimeZone.defaultTimeZone()
            notificationClass.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1

            UIApplication.sharedApplication().scheduledLocalNotifications = [notificationClass]


        }else{

            // call protocol function not support notification
        }

        return true
    }



    func araToString(numericString:String)->NSString
    {
        var nsMutString:NSMutableString = NSMutableString(string: numericString)
        let ArabicString:NSString = "١٢٣٤٥٦٧٨٩:"
        let EnglishString:NSString = "123456789:"

        for ( var i:Int = 0 ;   i < ArabicString.length ;  i++)
        {

            var a:NSString = ArabicString.substringWithRange(NSMakeRange(i, 1))

            var w:NSString = EnglishString.substringWithRange(NSMakeRange(i, 1))

            nsMutString.replaceOccurrencesOfString(a, withString: w, options: NSStringCompareOptions.LiteralSearch, range:NSMakeRange(0, nsMutString.length))


        }

        return nsMutString

    }


    func deleteAll(){

        let appnoti = UIApplication.sharedApplication()
        let delArray = appnoti.scheduledLocalNotifications
        if delArray.count > 0
        {
            appnoti.cancelAllLocalNotifications()

        }

    }

    func checkifNotificationOnOrOff()->Bool
    {

        let systemVer:String = UIDevice.currentDevice().systemVersion

        var finalFloat:Float = NSString(string: systemVer).floatValue

        if finalFloat < 8 {

            return false

        }else{

            return true
        }



    }
}

我的问题是计算一天中的提交次数

3 个答案:

答案 0 :(得分:15)

这回答了&#34;每天&#34;你问的身份危机问题的一面,似乎无法确定它是否需要每天/每天&#34;暗示多天或只是&#34;一天&#34;暗示单身。显然,&#34;每天&#34;是一个&#34;一天&#34;的超集,所以这是一个有用的展示; grep这样可以做其余的事情。

短而甜蜜:

git log --date=short --pretty=format:%ad | sort | uniq -c

示例输出:

      1 2017-12-08
      6 2017-12-26
     12 2018-01-01
     13 2018-01-02
     10 2018-01-14
      7 2018-01-17
      5 2018-01-18

说明:

    显然,
  • git log是先决条件。
  • --date=shortdate-format设置为YYYY-MM-DD,其中(A)是我们所需要的,(B)随后按字母顺序sort按时间顺序排列。
  • --pretty=format:%ad告诉git我们只想让每个提交a uthor d吃掉我们首选的date-format。如果你愿意,你可以使用cdc省略d吃,但只要cherry-pick rebase | sort uniq等等。
  • | uniq -c需要
  • YYYY-MM-DD,因为它只检查相邻的重复项。当然,我们几乎肯定希望最后订购日期。
  • to_double计算每个for col in cols10: if col.startswith('m_'): df[col] = df[col].astype(float) 的相邻重复项的数量,并预先计入日期。

答案 1 :(得分:5)

试试这个:

$ git rev-list --count --since=<start-date> --before=<end-date> <ref>

例如,要获取当前分支中昨天完成的提交次数:

$ git rev-list --count --since=yesterday --before=today HEAD

也接受绝对日期:

$ git rev-list --count --since=2016-03-02 --before=2016-03-03 HEAD

答案 2 :(得分:0)

我试过了:

  

git log | grep日期| awk&#39; {print&#34; :&#34; $ 4&#34; &#34; $ 3#34; &#34; $ 6}&#39; | uniq -c

它有效。你会得到类似的东西:

   5  : 3 Mar 2016
   4  : 2 Mar 2016
   8  : 1 Mar 2016
   [...]

我找到了命令here